X

The leading edge of scripting languages and Oracle Database brought to you by the Data Access Development team

  • php
    March 30, 2006

What packages do I use to connect to Oracle?

Christopher Jones
Senior Principal Product Manager

Which Oracle extension should you use? Some guidelines are:

  • If you want DB independence, consider PDO or an abstraction layer like PEAR DB (or PEAR MDB2) or ADOdb.
  • If you want to make full use of Oracle features and want high performance consider oci8. I've mostly worked with oci8; PDO is much newer since it first came out with PHP 5.1.
Where do you get the extensions? One option is to download PHP 5.1.2. This has the re-factored oci8 and PDO.

You can also get the re-factored oci8 for older versions of PHP including PHP 4, since the oci8 code compiles with PHP 4 and PHP 5.

All methods of getting oci8 derive from PHPs CVS:
  • The oci8 extension code is under continual maintenance in PHP's CVS source code control system. Anyone can access CVS and pull the code. (Anyone can contribute too). You can update your PHP environment by getting this source code and recompiling. It may be relatively unstable because it is under development.
  • PHP Extension Community Library (PECL) source code snapshots for oci8 are taken from CVS when it is in a known stable state. Windows binaries for oci8 compiled with various versions of PHP are on pecl4win. The version marked 1.2 is the re-factored extension.
  • Each new release of PHP includes the most current CVS code. The re-factored oci8 was picked up in PHP 5.1.2. Older versions of PHP have the old oci8 code.
  • Zend Core for Oracle (ZCO) takes snapshots from CVS and bundles them. ZCO has the re-factored oci8 extension and is not only the easiest way to install PHP, but gives you the option of a fully supported stack. ZCO currently uses PHP 5.0, so it does not have PDO.
The schedules of PHP releases, PECL snapshots and ZCO are not fully synchronized but currently the oci8 in ZCO 1.3.1 and PECL's oci8 1.2 are pretty close to each other.

PDO is a separate code base. It is also in CVS and has PECL snapshots created. It is not compatible with older versions of PHP.

Join the discussion

Comments ( 4 )
  • Francescom Thursday, March 30, 2006
    Thank you cj, I really like your blog and think it will be useful for a lot of us. I don't know if they changed the php_oci8.dll that is bundled with the PHP 5.1.2 distrubution (Windows) that is available on php.net. I had to replace that extension with the one available on PECL to make it work. After I did the switch everything ran fine.
  • Christopher Jones Thursday, March 30, 2006
    Thanks for the comment. There was one issue with 5.1.2 that could cause a crash on Windows due to threading. It was quickly patched and picked up in PECL's oci8. Ilia is already bundling up PHP 5.1.3 and looking for feedback on the release candidate. The Windows binaries should be available soon: http://news.php.net/php.internals/22620
  • Chris Monday, April 10, 2006
    Hello, Some of us can't recompile php and must use odbc. Can you describe how to to install the Oracle instant client, and the ODBC add on for unixODBC?
  • Christopher Jones Tuesday, April 11, 2006
    Good question. I'm going to take it on notice and add it to my list of things to research and write about.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.