OCI_ASSOC1.htm
objective: an Associative Array

OCI_ASSOC = returns string which are indexed.

 

Script:

<?php
$sql = "select empno, ename from emp WHERE rownum <=4";
$conn = oci_connect('scott', 'Son', 'localhost/orcl.gateway.2wire.net');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
//echo" DB connected: querying a table <br/>";
}
$stmt = oci_parse($conn, $sql);
oci_execute($stmt);
//
while ($row = oci_fetch_array($stmt, OCI_ASSOC )) {
echo $row['EMPNO'] . " ".$row['ENAME'] ." <br/>";
}
//
echo " no of rows : ". oci_num_rows($stmt);
oci_free_statement($stmt);
oci_close($conn);
echo "<br/> Oracle db conection closed";
//
?>
 

Runt time display