PHP PDO OCI: Access Oracle databases using a PDO class wrapper

Recommend this page to a friend!
  Info   Documentation   View files (8)   Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-02-01 (6 months ago) Not enough user ratingsTotal: 713 This week: 1All time: 4,577 This week: 255
Version License PHP version Categories
pdo-oci 1.0.21GNU General Publi...5PHP 5, Databases
Description Author

This class can access Oracle databases using a PDO class wrapper.

It provides a replacement for the PDO class that wraps around PHP Oracle OCI functions to access Oracle databases.

The class gets the available PDO drivers and insert the oci driver if it is not supported in the current PHP PDO installation.


What is the best PHP oracle oci8 class?
DB class with CRUD, Function calls, Stored Procedures

Innovation Award
PHP Programming Innovation award winner
March 2014

Prize: One downloadable e-book of choice by O'Reilly
PDO is a PHP extension that was introduced to provide a certain level of abstraction to access different types of databases.

However, sometimes it is necessary to access a database from components that use PDO, but the driver extension to access the specific type of database is not available in the current PHP environment.

This class implements a pure PHP replacement for PDO Oracle database driver, so it works with the OCI extension when the PDO OCI driver is not available.

Manuel Lemos
Picture of Eustaquio Rangel de Oliveira Jr.
  Performance   Level  
Name: Eustaquio Rangel de ... is available for providing paid consulting. Contact Eustaquio Rangel de ... .
Classes: 6 packages by
Country: Brazil Brazil
Age: 49
All time rank: 27821 in Brazil Brazil
Week rank: 243 13 in Brazil Brazil
Innovation award
Innovation award
Nominee: 3x

Winner: 1x



Wrapping on PHP OCI functions to simulate a PDO object, using just pure PHP and the oci_* functions.

Let's face it. Installing PHP, PDO, Oracle drivers and PDO OCI is not a pleasant task. Is more pleasant to insert bamboo sticks under your fingernails than make all the voodoo needed to accomplish that task. And there are two big problems with that:

  1. If you install `pdo_oci` with `pecl` you'll get a version from 2005 ( Even Christian Bale is now far from the things from 2005, and wow, he had a cool suit and a very nice car. And all came in black.
  2. If you follow the official docs, you'll need to compile PHP and still get an experimental extension ( Come on. We can't (yeah, we know how to do it!) compile PHP on every server we need and just for an experimental feature?

That's why I made PDOOCI.


First install the Oracle drivers (I like the instant client versions) and the oci8 package (with pecl, this one seems to be updated often).

With Composer

$ composer require taq/pdooci

    "require": {
        "taq/pdooci": "^1.0"

require_once 'vendor/autoload.php';

$pdo = new PDOOCI\PDO("mydatabase", "user", "password");

Without Composer

Why are you not using composer? Download the src folder from the repo and rename it to PDOOCI, then require the PDOOCI/PDO.php file.

require_once "PDOOCI/PDO.php";

$pdo = new PDOOCI\PDO("mydatabase", "user", "password");

Yeah, the rest should work exactly the same as if you were using a PDO object. :-)


There is a test suite (using PHPUnit with a version bigger than 6.x) on the test directory. If you want to test (you must test your code!), create a table called people with two columns:

  1. `name` as `varchar2(50)`
  2. `email` as `varchar2(30)`

And some environment variables:

  1. `PDOOCI_user` with the database user name
  2. `PDOOCI_pwd` with the database password
  3. `PDOOCI_str` with the database connection string

And then go to the test dir and run PHPUnit like:

phpunit --colors .
File Role Description
src (3 files)
test (2 files)
composer.json Data Auxiliary data
LICENSE Lic. Auxiliary data Doc. Auxiliary data

  Files  /  src  
File Role Description
   PDO.php Class Class source
   Statement.php Class Class source
   StatementIterator.php Class Class source

  Files  /  test  
File Role Description
   connectionTest.php Test Unit test script
   statementTest.php Test Unit test script

 Version Control Unique User Downloads Download Rankings  
This week:1
All time:4,577
This week:255

For more information send a message to info at phpclasses dot org.