note 14173 added to ref.oci8.php
| From: | doug at redhive dot com | Date: | Thu, 19 Jul 2001 18:38:52 +0000 |
| Subject: | note 14173 added to ref.oci8.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15597@lists.php.net to get a copy of this message | ||
if you feel like you have too many oracle statements clouding up your php, i came up with a function
to open a connection (if necessary), parse your sql statement, and return the executed query. after
you call the function, you can do whatever needs to be done. makes like so much simpler: (do
whatever you want with the errors)
function execute_query($query, &$connected) {
global $ORACLE_USER, $ORACLE_PASS, $ORACLE_SID;
if(!$connected) {
$connected = @OCIPLogon($ORACLE_USER, $ORACLE_PASS, $ORACLE_SID);
if($error = OCIError()) {
die("<font color=red>ERROR!! Couldn't connect to
server!</font>");
}
}
$stmt = @OCIParse($connected, $query);
if($error = OCIError($cn)) {
die("<font color=red>ERROR!! Statement syntax error!</font>");
}
@OCIExecute($stmt);
if($error = OCIError($stmt)) {
die("<font color=red>ERROR!! Could not execute statement!</font>");
}
return $stmt;
}
http://www.php.net/manual/en/ref.oci8.php