I can connect to the MySQL database with ODBC/SSL ( see my post ) with this script:
ini_set ('error_reporting', E_ALL);
ini_set ('display_errors', '1');
error_reporting (E_ALL|E_STRICT);
$user = "odbcmmm";
$pass = "999999999";
$connection = "Driver={mysql537};Server=99.99.199.199;Database=db_name;UID=odbc_db_name;PWD=password;sslca=/etc/mysql/ssl/c1.pem;sslkey=/etc/mysql/ssl/ck.pem;sslcapath=/etc/mysql/ssl/;sslcert=/etc/mysql/ssl/cc.pem";
$con = odbc_connect($connection, $user, $pass);
$sql="SELECT Id from stk_item";
$rs=odbc_exec($con,$sql);
if (!$rs) {
exit("Error in SQL");
}
However when I try an create a PDO object using the script below I get the error:
SQLSTATE[IM002] SQLDriverConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified**
<?php
ini_set ('error_reporting', E_ALL);
ini_set ('display_errors', '1');
$pass = "pass";
try {
$connection = new PDO("odbc:mysql537;Server=99.99.199.199;Database=db1;UID=user1;PWD=pwd1;sslca=/etc/mysql/ssl/c1.pem;sslkey=/etc/mysql/ssl/ck.pem;sslcapath=/etc/mysql/ssl/;sslcert=/etc/mysql/ssl/cc.pem");
error_reporting (E_ALL|E_STRICT);
} catch (PDOException $exception) {
echo $exception->getMessage();
exit;
}
When I change the code as below the error is:
invalid data source name
<?php
ini_set ('error_reporting', E_ALL);
ini_set ('display_errors', '1');
error_reporting (E_ALL|E_STRICT);
$user = "user";
$pass = "pass";
try {
$connection = new PDO("Driver={mysql537};Server=99.99.199.199;Database=db1;UID=user1;PWD=pwd1;sslca=/etc/mysql/ssl/c1.pem;sslkey=/etc/mysql/ssl/ck.pem;sslcapath=/etc/mysql/ssl/;sslcert=/etc/mysql/ssl/cc.pem");
} catch (PDOException $exception) {
echo $exception->getMessage();
exit;
}
I know that PDO ODBC drivers are installed via phpinfo, so I must be messing up the PDO ODBC connection syntax somewhere. Any help to spot my mistake, much appreciated. Thanks.