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.