<?php
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$stid = oci_parse($conn, 'SELECT POSTAL_CODE, CITY FROM locations WHERE ROWNUM < 3');
oci_execute($stid);
$nrows = oci_fetch_all($stid, $res, null, null, OCI_FETCHSTATEMENT_BY_ROW);
echo "$nrows rows fetched<br>\n";
var_dump($res);
/ Output is:
/ 2 rows fetched
/ array(2) {
/ [0]=>
/ array(2) {
/ ["POSTAL_CODE"]=>
/ string(6) "00989x"
/ ["CITY"]=>
/ string(4) "Roma"
/ }
/ [1]=>
/ array(2) {
/ ["POSTAL_CODE"]=>
/ string(6) "10934x"
/ ["CITY"]=>
/ string(6) "Venice"
/ }
/ }
oci_free_statement($stid);
oci_close($conn);
?>