avatar

Andres Jaimes

PHP

By Andres Jaimes

Connecting to a Local Oracle Database

This is a small but useful example:

<?php
$c = oci_connect('hr', 'hr', '//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);
?>

Prior to use this example you must enable the hr user. To learn how to configure PHP to access Oracle databases check my Linux Console page.

Source: http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf