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

(singke) #1
Table 13.10. Constants for Use with ocifetchinto
Constant Description

OCI_ASSOC (^) Return columns indexed by name
OCI_NUM (^) Return columns indexed by number
OCI_RETURN_NULLS (^) Create elements for null columns
OCI_RETURN_LOBS (^) Return values of LOBs instead of descriptors
<?
//connect to database
$Connection = ocilogon("scott", "tiger");
//assemble query
$Query = "SELECT * ";
$Query .= "FROM emp ";
//parse query
$Statement = ociparse($Connection, $Query);
//execute query
ociexecute($Statement);
//check that the query executed sucessfully
if($Error = ocierror($Statement))
{
print($Error["code"]. ": ". $Error["message"].
"
\n");
exit;
}
//start HTML table
print("

\n");
//fetch each row
while(ocifetchinto($Statement, $Data,
OCI_NUM + OCI_RETURN_NULLS + OCI_RETURN_LOBS))
{
print("\n");
//loop over each column
while(list($key, $value) = each($Data))
{
//print a line like ""
print("\n");
}
print("\n");
}
//close table
print("
SMITH$value
\n");
//free the statement
ocifreestatement($Statement);

Free download pdf