From 6685437591c9dbfbe14ea23543779ce613d57a67 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Sat, 14 Nov 2009 02:28:01 +0000 Subject: [PATCH] Update and describe the error array git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@290733 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/oci8/functions/oci-error.xml | 116 +++++++++++++++++-------- 1 file changed, 82 insertions(+), 34 deletions(-) diff --git a/reference/oci8/functions/oci-error.xml b/reference/oci8/functions/oci-error.xml index 7d29346b56..b61d37bea6 100644 --- a/reference/oci8/functions/oci-error.xml +++ b/reference/oci8/functions/oci-error.xml @@ -10,11 +10,15 @@ &reftitle.description; arrayoci_error - resourcesource + resourceresource Returns the last error found. + + The function should be called immediately after an error occurs. + Errors are cleared by a successful statement. + @@ -22,13 +26,14 @@ - source + resource - For most errors, the parameter is the most appropriate resource - handle. For connection errors with oci_connect, + For most errors, resource is the + resource handle that was passed to the failing function call. + For connection errors with oci_connect, oci_new_connect or - oci_pconnect do not pass a parameter. + oci_pconnect do not pass resource. @@ -39,11 +44,56 @@ &reftitle.returnvalues; - If no error is found, oci_error - returns &false;. oci_error returns the error as an - associative array. In this array, code - consists the oracle error code and message - the oracle error string. + If no error is found, oci_error returns + &false;. Otherwise, oci_error returns the + error information as an associative array. + + + + <function>oci_error</function> Array Description + + + + + Array key + Type + &Description; + + + + + code + integer + + The Oracle error number. + + + + message + string + + The Oracle error text. + + + + offset + integer + + The byte position of an error in the SQL statement. If there + was no statement, this is 0 + + + + sqltext + string + + The SQL statement text. If there was no statement, this is + an emptry string. + + + + +
@@ -60,11 +110,10 @@ - 4.3 + PHP 4.3 - offset and sqltext will - also be included in the return array to indicate the location - of the error and the original SQL text which caused it. + The offset and sqltext + entries were added. @@ -80,10 +129,10 @@ Displaying the Oracle error message after a connection error @@ -94,10 +143,10 @@ if (!$conn) { Displaying the Oracle error message after a parsing error @@ -105,18 +154,19 @@ if (!$stmt) {
- Displaying the Oracle error message and problematic statement - after an execution error + Displaying the Oracle error message, the problematic statement, + and the position of the problem of an execution error "; - echo htmlentities($e['sqltext']); - printf("\n%".($e['offset']+1)."s", "^"); - echo ""; + $e = oci_error($stid); // For oci_execute errors pass the statement handle + print htmlentities($e['message']); + print "\n
\n";
+    print htmlentities($e['sqltext']);
+    printf("\n%".($e['offset']+1)."s", "^");
+    print  "\n
\n"; } ]]>
@@ -128,10 +178,8 @@ if (!$r) { &reftitle.notes; - In PHP versions before 5.0.0 you must use ocierror instead. - This name still can be used, it was left as alias of - oci_error for downwards compatability. - This, however, is deprecated and not recommended. + In PHP versions before 5.0.0 you must + use ocierror instead. &oci.name.compat.note;