PHP Oracle Extension - OCI8

This sections will contains code regarding different PHP & MySQL features and contains help about php/mysql issues.

PHP Oracle Extension - OCI8

Postby Web Guru on March 25th, 2008, 5:33 am

The name “OCI8” is the name for PHP’s Oracle extension, which provides PHP function calls to access an Oracle database. It is also the name for Oracle's Call Interface API used by C programs including the PHP extension. All unqualified references to OCI8 in this book refer to the PHP extension.

The OCI8 extension is included in PHP 3, 4 and 5. The OCI8 extension accesses the database
using Oracle’s C code OCI8 API.

OCI8 was refactored by Zend and Oracle for stability and performance. The new code is included in PHP 5.1.2 onwards. The PHP interfaces are the same as the original OCI8 extension but there are new connection management and performance settings. The refactored extension is designed to work with PHP4 and PHP5. If you are using PHP4 and cannot upgrade, you can replace just the original OCI8 code with the new version. Zend have also bundled the new code into the easy to install Zend Core for Oracle (ZCO).

intro.php
Code: Select all
<?php
$c = oci_connect('hr', 'hr_password', '//localhost/XE');
$s = oci_parse($c, 'select city from locations');
oci_execute($s);
while ($res = oci_fetch_array($s)) {
echo $res['CITY'] . "<br>";
}
oci_close($c);
?>

When invoked in a web browser, it connects to Oracle as the demonstration user, HR, of the Oracle XE database running on the local machine. The query is executed and a web page of results is displayed in the browser.
User avatar
Web Guru
 
Posts: 66
Joined: March 24th, 2008, 7:59 am
Location: Lahore, Pakistan

Return to PHP / MySQL / XML

Who is online

Users browsing this forum: No registered users and 0 guests