note 20005 deleted from function.ocierror by alindeman

From: Date: Tue, 19 Mar 2002 00:34:45 +0000
Subject: note 20005 deleted from function.ocierror by alindeman
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-27937@lists.php.net to get a copy of this message
// ATTENTION NOTES MODERATOR, THERE'S A COMMENT BELOW WITH SOME INSTRUCTIONS...PLEASE READ IT AND FOLLOW THE INSTRUCTIONS, IF IT'S NOT TOO MUCH TO ASK...THANKS (DON'T FORGET TO REMOVE THESE 'NOTES MODERATOR' COMMENTS :) Hi, I thought I'd include an example on how to use the above patch, which has been recently commited to CVS. <? $conn = OCILogon ("bla", "bla", "bla"); // I'm very anal about formatting $sql = " select t.foo, t.bar from table t where t.id = 1"; $stmt = OCIParse ($conn, $sql); // Suppress the warning generated here using @ @OCIExecute ($stmt, OCI_DEFAULT); $error = OCIError ($stmt); // ATTENTION NOTES MODERATOR!! CAN YOU PLEASE CLEAN UP THE CODE BELOW? IT LOOKS LIKE ASS WHEN I PREVIEW AND I CAN'T GET IT TO LOOK ANY BETTER THAN THIS...THANKS if ($error["code"]) { $sqltext = substr ($error["sqltext"], 0, $error["offset"]) . '<span style="color:#FF0000; font-weight:bold">&lt;ERROR&gt;</span>' . substr ($error["sqltext"], $error["offset"]); die ("<pre>" . $sqltext . "\n\n</pre>\n" . $error["code"] . " : " . $error["message"]); } ?> Assuming the column "bar" doesn't exist in table "t", the above code will print: // ATTENTION NOTES MODERATOR!! CAN YOU ALSO PLEASE MAKE THIS ONE LINE HERE NOT WRAP? THANKS select t.foo, t.<span style="color:#FF0000; font-weight:bold">&lt;ERROR&gt;</span>bar from table t where t.id = 1 904 : ORA-00904: invalid column name Of course, the best way to do this is by using a class to wrap all the OCI calls, which I'm sure you already do. :) Daniel Ceregatti

« previous php.notes (#27937) next »