Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

//close connection
ocilogoff($Connection);
?>


integer ocifetchstatement(integer statement, reference data)


The ocifetchstatement function places an array with all the result data in the data
argument and returns the number of rows. The data array is indexed by the names of the
columns. Each element is an array itself which is indexed by integers starting with zero.
Each element in this subarray corresponds to a row.


<?
//connect to database
$Connection = ocilogon("scott", "tiger");


//assemble query
$Query = "SELECT * ";
$Query .= "FROM emp ";


//parse query
$Statement = ociparse($Connection, $Query);


//execute query
ociexecute($Statement);


print("

\n");


//fetch all rows into array
if($Rows = ocifetchstatement($Statement, &$Data))
{
while(list($key, $value) = each($Data))
{
print("

\n");


//name of column
print("

\n");
}
}


print("

$key/TH>\n");


//print data
for($i=0; $i < $Rows; $i++)
{
print("

$value[$i]/\n");
}


print("

\n");


//free the statement
ocifreestatement($Statement);

Free download pdf