tony2001                Mon May 24 03:14:40 2004 EDT

  Modified files:              
    /phpdoc/en/reference/oci8/functions oci-error.xml 
  Log:
  change function description as was proposed by Christopher and add some examples 
  
  
http://cvs.php.net/diff.php/phpdoc/en/reference/oci8/functions/oci-error.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/oci8/functions/oci-error.xml
diff -u phpdoc/en/reference/oci8/functions/oci-error.xml:1.2 
phpdoc/en/reference/oci8/functions/oci-error.xml:1.3
--- phpdoc/en/reference/oci8/functions/oci-error.xml:1.2        Thu Apr  1 03:11:26 
2004
+++ phpdoc/en/reference/oci8/functions/oci-error.xml    Mon May 24 03:14:40 2004
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
   <refentry id="function.oci-error">
    <refnamediv>
     <refname>oci_error</refname>
@@ -12,13 +12,11 @@
       <methodparam 
choice="opt"><type>resource</type><parameter>source</parameter></methodparam>
      </methodsynopsis>
     <para>
-     <function>oci_error</function> returns the last error found.  If
-     the optional <parameter>source</parameter> is not
-     provided, the last error encountered is returned. You can use
-     connection or statement resources as value of parameter 
-     <parameter>source</parameter>. If no error is
-     found, <function>oci_error</function> returns
-     &false;. <function>oci_error</function> returns the error as an
+     For most errors, the parameter is the most appropriate resource
+     handle. For connection errors with <function>oci_connect</function>, 
+     <function>oci_new_connect</function> or <function>oci_pconnect</function>,
+     do not pass a parameter. If no error is found, <function>oci_error</function> 
+     returns &false;. <function>oci_error</function> returns the error as an
      associative array. In this array, <literal>code</literal>
      consists the oracle error code and <literal>message</literal>
      the oracle error string.
@@ -31,6 +29,53 @@
       of the error and the original SQL text which caused it.
      </para>
     </note>
+    <para>
+     <example>
+      <title>Displaying the Oracle error message after a connection error</title>
+      <programlisting role="php">
+<![CDATA[
+$conn = @oci_connect("scott", "tiger", "mydb");
+if (!$conn) {
+  $e = oci_error();   // For oci_connect errors pass no handle
+  echo htmlentities($e['message']);
+}
+]]>
+      </programlisting>
+     </example> 
+    </para>
+    <para>
+     <example>
+      <title>Displaying the Oracle error message after a parsing error</title>
+      <programlisting role="php">
+<![CDATA[
+$stmt = @oci_parse($conn, "select ' from dual");  // note mismatched quote
+if (!$stmt) {
+  $e = oci_parse($conn);  // For oci_parse errors pass the connection handle
+  echo htmlentities($e['message']);
+}
+]]>
+      </programlisting>
+     </example>
+    </para>
+    <para>
+     <example>
+      <title>Displaying the Oracle error message and problematic statement 
+       after an execution error</title>
+      <programlisting role="php">
+<![CDATA[
+$r = oci_execute($stmt);
+if (!$r) {
+  $e = oci_error($stmt); // For oci_execute errors pass the statementhandle
+  echo htmlentities($e['message']);
+  echo "<pre>";
+  echo htmlentities($e['sqltext']);
+  printf("\n%".($e['offset']+1)."s", "^");
+  echo "</pre>";
+}     
+]]>
+      </programlisting>
+     </example>
+    </para>
     <note>
      <para>
       In PHP versions before 5.0.0 you must use <function>ocierror</function> 
instead. 

Reply via email to