I am trying to develop a web app that can connect to as many different databases as possible on PHP. PDO (http://www.php.net/manual/en/book.pdo.php) seems to be the right interface for it but I am having trouble installing all the extentions needed for all the different PDO database drivers that I need.
Please note that I use xampp on a windows 7 machine. PHP Version 5.3.8. PDO drivers enabled mysql, odbc, sqlite, sqlite2, sqlsrv.
I have successfully connected with the following:
- MySQL using PDO_MYSQL [MySQL (PDO) ] (extension seemed to be installed on xampp by default)
- Microsoft SQL Server using PDO_SQLSRV [MS SQL Server (PDO)] (followed the instractions on http://craigballinger.com/blog/2011/08/usin-php-5-3-with-mssql-pdo-on-windows/)
I had no luck installing or connecting with:
- (SOLVED SEE BELOW UPDATES) Sybase (I tried to use and install PDO_DBLIB [MS SQL Server (PDO)]but with no luck)
- (SOLVED SEE BELOW UPDATES)Oracle (I tried to enable the extension=php_pdo_oci.dll in php.ini with the dll that was installed with xampp after restarting Apache the server failed to start. Was trying to use PDO_OCI [Oracle (PDO)])
I know I can work around those 2 with using the database specific drivers but I would really love to use PDO for everything that I need.
Does anyone know how to install and enable PDO_DBLIB and PDO_OCI drivers or a windows machine, or any other way of connecting with Sybase and Oracle databases using PDO?
UPDATE
Just succesfully connected with oracle with PDO_OCI. What you need to do is the following:
Download and install the proper Oracle Instant Client on your windows machine for example instantclient_12_1 and add its path to PATH in SYSTEM Environmental Variables. Note Oracle supports only 2 versions down so select your client version properly. Do that and then restart your Apache. Note that the connection string is very different from here is a sample of what I used:
$tns = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ".$myServer.")(PORT = 1521)))(CONNECT_DATA=(SID=".$myDB.")))";
$connStr = "oci:dbname=".$tns;
$conn = new PDO($connStr,$myUser,$myPass);
UPDATE
Just connected with Sybase as well with PDO_ODBC. What you need is the following:
Must have Sybase ASE ODBC Driver which comes with the SDK. Find below the connection string used:
$connStr = "odbc:Driver={Adaptive Server Enterprise};server=".$myServer.";port=".$myPort.";db=".$myDB;
$conn = new PDO($connStr,$myUser,$myPass);