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

(singke) #1

boolean ora_exec(integer cursor)


The ora_exec function executes a query previously parsed by the ora_parse function.
Compare this function to ora_do.


<?
//in case these aren't set for httpd
putenv("ORACLE_HOME=/usr/local/oracle7");
putenv("ORACLE_SID=ORCL");


function reportError($id, $message)
{
print("$message
\n");


print("Error Code: ". ora_errorcode($id). "
\n");


print("Error Message: ". ora_error($id). "
\n");
}


//connect to server
if(!($Connection = ora_logon("scott", "tiger")))
{
print("Could not connect to database!
\n");
exit;
}


//open cursor
if(!($Cursor = ora_open($Connection)))
{
reportError($Connection, "Cursor could not be opened!");
exit;
}


$Query = "SELECT * ";
$Query .= "FROM emp ";


//parse query
if(!ora_parse($Cursor, $Query))
{
reportError($Cursor, "Statement could not be parsed!");
exit;
}


// execute query
if(!ora_exec($Cursor))
{
reportError($Cursor, "Statement could not be executed!");
exit;
}


//start table
print("<TABLE BORDER=\"1\">\n");


//print header row that describes each column
print("\n");

Free download pdf