PHP Classes

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

Recommend this page to a friend!
  Info   View files Documentation   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-01-09 (3 days ago) RSS 2.0 feedNot enough user ratingsTotal: 775 This week: 1All time: 4,372 This week: 348Up
Version License PHP version Categories
pdo-oci 1.0.34GNU 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.

Innovation Award
PHP Programming Innovation award winner
March 2014
Winner


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 ... <contact>
Classes: 6 packages by
Country: Brazil Brazil
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

Recommendations

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

Documentation

PDOCI

| :warning: WARNING This software is abandonware. As the creator and maintainer, I don't even use PHP or Oracle _for years_, so, I can't support it anymore. It should work ok for PHP untill version 7, but seems that with 8.1 there are some alerts. Feel free to fork it and keep it going. | | --- |

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 (http://pecl.php.net/package/PDO_OCI). 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 (http://www.php.net/manual/ref.pdo-oci.php). 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.

Installation

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"
    }
}

<?php
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. :-)

Testing

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

Don't forget to run composer install!

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

phpunit --colors .

  Files folder image Files  
File Role Description
Files folder imagesrc (3 files)
Files folder imagetest (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. Auxiliary data
Accessible without login Plain text file README.md Doc. Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file PDO.php Class Class source
  Plain text file Statement.php Class Class source
  Plain text file StatementIterator.php Class Class source

  Files folder image Files  /  test  
File Role Description
  Accessible without login Plain text file connectionTest.php Test Unit test script
  Accessible without login Plain text file statementTest.php Test Unit test script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:775
This week:1
All time:4,372
This week:348Up