How are database errors handled in PHP?
Submitted by admin on Sun, 2005-11-06 02:27.
When using the OCI extension Module, the OCIError() function can be used to obtain an array with error code, message, offset and SQL text. One can also obtain the error for a specific session or cursor by supplying the appropriate handle as an argument to OCIError(). Without any arguments, OCIError() will return the last encountered error.
<?php $err = OCIError(); var_dump($err); print "nError code = " . $err[code]; print "nError message = " . $err[message]; print "nError position = " . $err[offset]; print "nSQL Statement = " . $err[sqltext]; ?>
When using the ORA Extension Module, one can use the ora_error() and ora_errorcode() functions to report errors:
<?php print "nError code = " . ora_errorcode(); print "nError message = " . ora_error(); ?>
»
- Login to post comments

