SQL: September 2010 Archives

Build PHP with OCI8

user-pic
Vote 0 Votes

Environment: CentOS 5.5 x64

1. Download Oracle Instant Client basic and devel rpm and install
(You need to register an oracle account first)
rpm -ivh oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-devel-11.2.0.1.0-1.x86_64.rpm

2. Downlaod Extension for Oracle Database from PECL and install
wget http://pecl.php.net/get/oci8-1.4.3.tgz
pecl install oci8-1.4.3.tgz

3. Move oci8.so to extension_dir (see your php.ini)
cp /usr/local/lib/php/extensions/no-debug-non-zts-20060613/oci8.so /usr/lib64/php/modules

4. add extension=oci8.so to php.ini
echo extension=oci8.so >> /usr/local/etc/php.ini

Verifying the oci8 extension is work
# php -i | grep OCI
OCI8 Support => enabled

Easy Connect Example:
$conn = oci_connect('user', 'password', '//172.29.2.2/service_name');
// Use lsnrctl services in Oracle to list existing service name
$stid = oci_parse($conn, "select id from table");
oci_execute($stid, OCI_DEFAULT);
while ($arr = oci_fetch_array($stid, OCI_ASSOC)) {
echo "$arr[id].\n";
}

ref. Installing PHP and the Oracle Instant Client for Linux and Windows
PHP Oracle FAQThis is a featured page
PHP: oci_connect - Manual

About this Archive

This page is an archive of entries in the SQL category from September 2010.

SQL: April 2010 is the previous archive.

SQL: October 2010 is the next archive.

Find recent content on the main index or look in the archives to find all content.