ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:database:oracle

This is an old revision of the document!


Oracle

For more information on using advanced functionality in the Oracle driver, read the Advanced Oracle Tutorial

oci8

Specification
Driver Nameoci8
Data Provideroracle
StatusActive1)
WindowsYes
UnixYes
ADOdb V5Yes
ADOdb V6Yes
Alternatives

Alternative Drivers
PDO driver for Oracle
ADO driver for Oracle

This is the preferred driver for connecting to Oracle databases Despite its name, this driver supports Oracle databases up to and including Oracle 11.


Driver Specific Methods

Non portable methods are not declared in the base class. Use of these methods in portable code will cause a fatal error when used with other drivers.

The following non-portable methods are available to this driver

Method Description
bind() A fast way of updating records
executeCursor() Returns a cursor to procedure as a handle

Connection Examples

a. PHP and Oracle reside on the same machine, use default SID, with non-persistent connections:

$conn = NewADOConnection('oci8');
$conn->connect(false, 'scott', 'tiger');

b. TNS Name defined in tnsnames.ora (or ONAMES or HOSTNAMES), eg. 'myTNS':

$conn = NewADOConnection('oci8');
$conn->connect(false, 'scott', 'tiger', 'myTNS');

or

$conn->connect('myTNS', 'scott', 'tiger');

c. Host Address and SID

$conn->connectSID = true;
$conn->connect('192.168.0.1', 'scott', 'tiger', 'SID');

d. Host Address and Service Name

$conn->connect('192.168.0.1', 'scott', 'tiger', 'servicename');

e. Oracle connection string:

$cstr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
                               (HOST=$host)
                               (PORT=$port)
                      )
                      (CONNECT_DATA=(SID=$sid)
                      )
         )";
$conn->connect($cstr, 'scott', 'tiger');

f. ADOdb data source names (dsn):

$dsn = 'oci8://user:pwd@tnsname/?persist';  # persist is optional
$conn = ADONewConnection($dsn);  # no need for Connect/PConnect
$dsn = 'oci8://user:pwd@host/sid';
$conn = ADONewConnection($dsn);
$dsn = 'oci8://user:pwd@/';   # oracle on local machine
$conn = ADONewConnection($dsn);

With ADOdb data source names, there is no need to call connect() or pConnect() as this is done automatically.


Date Format

By default, after connection the following SQL is issued:

"ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'"

The default value for NLS_DATE_FORMAT is YYYY-MM-DD. To include time as well, use RRRR-MM-DD HH24:MI:SS or set the value to empty to disable this action.

oci8po

Specification
Driver Nameoci8po
Data Provideroracle
StatusActive2)
WindowsYes
UnixYes
ADOdb V5Yes
ADOdb V6Yes

This driver extends the oci8 driver and provides compatibility with other database drivers such as MySQL and SQL Server. Use this version of the driver if you are writing portable code.


oci805

Specification
Driver Nameoci805
Data Provideroracle
StatusInactive3)
WindowsYes
UnixYes
ADOdb V5Yes
ADOdb V6Yes

This driver provides an undocumented enhancement to the oci8 driver


oci8quercus

Specification
Driver Nameoci805cus
Data Provideroracle
StatusInactive4)
WindowsYes
UnixYes
ADOdb V5Yes
ADOdb V6Yes

This driver provides an undocumented enhancement to the oci8 driver


oracle

Support for oracle databases versions 7 and lower was removed in PHP version 5.1. In ADOdb version 6, the Oracle driver will be removed

Specification
Driver Nameoracle
Data Provideroracle
StatusObsolete5)
WindowsYes
UnixYes
ADOdb V5Yes
ADOdb V6No

This driver provided support to oracle 7 and lower databases. The driver is obsolete, and not supported by PHP and will be removed in ADOdb version 6.0 The data provider name 'oracle' will be assigned to the oci8 driver. The oci8 driver will become a stub to provide backwards compatibility.

1) , 2)
This driver is actively supported by ADOdb project members
3) , 4)
This driver is obsolete is not actively supported or enhanced by ADOdb project members, but you can provide fixes and enhancements if you have the expertise
5)
This driver is not maintained and will be removed in ADOdb V6
v5/database/oracle.1454182205.txt.gz · Last modified: 2017/04/21 11:24 (external edit)