Enabling PDO OCI

Warej picture Warej · Jan 20, 2014 · Viewed 16.9k times · Source

I've tried to install OCI, so I can use new PDO("oci:dbname...

After 1,5h of fight I've installed oracle instantclient (basic and sdk) and then oci for php (as described here http://ubuntuforums.org/showthread.php?t=92528).

Now I'm a bit confused because my PHPinfo tells that OCI8 Support is enabled, but in PDO section there's only odbc in "PDO drivers" section.

When did I go wrong?

P.S. I've got XUBUNTU 12.10 and following packets installed: php-pear, php5, php5-cli, php5-common, php5-dbg, php5-dev, php5-odbc

Edit: Thanks for explaining. Now I'm trying to install "pdo_oci" following this: http://lacot.org/blog/2009/11/03/ubuntu-php5-oci8-and-pdo_oci-the-perfect-install.html

and now invoking this:

/usr/local/src/PDO_OCI-1.0# ./configure --with-oci8=instantclient,/opt/oracle/instantclient,12.1

I'm getting following error:

configure: error: Oracle-OCI needed libraries not found under /opt/oracle/instantclient

I wonder if doing this on Windows wouldn't be easier.

Answer

Álvaro González picture Álvaro González · Jan 20, 2014

You should note that there're two completely different PHP extensions designed to connect to Oracle databases:

  • OCI8 is the extension developed by Oracle Corporation. It's actively maintained and it's the recommended way to interact with Oracle.

  • PDO_OCI is the PDO driver developed by the community. It was never finished and it's actually kind of abandoned (thus the EXPERIMENTAL warning displayed in the documentation).

Both contain the OCI (Oracle Call Interface) term because both make use internally of the OCI API provided by Oracle. As such, you need the Oracle Instant Client no matter what library you choose. But you then need to install the corresponding PHP packages.

In your case, you're installing OCI8 and then trying to run PDO code.