dbs             Fri Nov 26 15:12:47 2004 EDT

  Modified files:              
    /phpdoc/en/reference/pdo/functions  PDO-errorCode.xml 
                                        PDO-errorInfo.xml 
  Log:
  Document database handle error methods.
  
  
http://cvs.php.net/diff.php/phpdoc/en/reference/pdo/functions/PDO-errorCode.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/pdo/functions/PDO-errorCode.xml
diff -u phpdoc/en/reference/pdo/functions/PDO-errorCode.xml:1.1 
phpdoc/en/reference/pdo/functions/PDO-errorCode.xml:1.2
--- phpdoc/en/reference/pdo/functions/PDO-errorCode.xml:1.1     Wed Nov 10 
17:21:21 2004
+++ phpdoc/en/reference/pdo/functions/PDO-errorCode.xml Fri Nov 26 15:12:46 2004
@@ -1,5 +1,5 @@
 <?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
 <!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. 
-->
   <refentry id="function.PDO-errorCode">
    <refnamediv>
@@ -15,7 +15,72 @@
      <void/>
     </methodsynopsis>
 
-     &warn.undocumented.func;
+     &warn.experimental.func;
+    <para>
+     Returns an integer value that maps to the generic error categories
+     defined in the <literal>PDO_ERR_*</literal> set of constants.
+    </para>
+    <para>
+     <function>PDO::errorCode</function> only retrieves error codes for 
operations
+     performed directly on the database handle. If you create a PDOStatement
+     object through <function>PDO::prepare</function> or
+     <function>PDO::query</function> and invoke an error on the statement
+     handle, <function>PDO::errorCode</function> will return
+     <literal>PDO_ERR_NONE</literal>. You must call
+     <function>PDOStatement::errorCode</function> to return the error
+     code for an operation performed on a particular statement handle.
+    </para>
+    <example><title>Determining which category of error occurred</title>
+     <programlisting role="php">
+<![CDATA[
+<?php
+/* Provoke an error -- the BONES table does not exist */
+$dbh->exec("INSERT INTO bones(skull) VALUES ('reagan')");
+
+echo "\nPDO::errorCode(): ";
+switch ($dbh->errorCode()) {
+    case PDO_ERR_NONE:
+        echo "No error!\n";
+        break;
+    case PDO_ERR_CANT_MAP:
+        echo "Error: Unable to map data types between database and PHP.\n";
+        break;
+    case PDO_ERR_SYNTAX:
+        echo "Error: incorrect syntax\n";
+        break;
+    case PDO_ERR_CONSTRAINT:
+        echo "Error: The request would violate a constraint.\n";
+        break;
+    case PDO_ERR_NOT_FOUND:
+        echo "Error: The object could not be found.\n";
+        break;
+    case PDO_ERR_ALREADY_EXISTS:
+        echo "Error: The object already exists.\n";
+        break;
+    case PDO_ERR_NOT_IMPLEMENTED:
+        echo "Error: The requested function is not implemented.\n";
+        break;
+    case PDO_ERR_MISMATCH:
+        echo "Error: mismatch\n";
+        break;
+    case PDO_ERR_TRUNCATED:
+        echo "Error: The value was truncated because the input value was longer
+    than the maximum column length.\n";
+        break;
+    case PDO_ERR_DISCONNECTED:
+        echo "Error: The connection to the requested database has been 
closed.\n";
+        break;
+}
+?>
+]]>
+     </programlisting>
+    </example>
+    &example.outputs;
+    <screen>
+<![CDATA[
+PDO::errorCode(): Error: The object could not be found.
+]]>
+    </screen>
 
    </refsect1>
   </refentry>
http://cvs.php.net/diff.php/phpdoc/en/reference/pdo/functions/PDO-errorInfo.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/pdo/functions/PDO-errorInfo.xml
diff -u phpdoc/en/reference/pdo/functions/PDO-errorInfo.xml:1.2 
phpdoc/en/reference/pdo/functions/PDO-errorInfo.xml:1.3
--- phpdoc/en/reference/pdo/functions/PDO-errorInfo.xml:1.2     Thu Nov 11 
03:16:32 2004
+++ phpdoc/en/reference/pdo/functions/PDO-errorInfo.xml Fri Nov 26 15:12:46 2004
@@ -1,5 +1,5 @@
 <?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
 <!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. 
-->
   <refentry id="function.PDO-errorInfo">
    <refnamediv>
@@ -15,7 +15,79 @@
      <void/>
     </methodsynopsis>
 
-     &warn.undocumented.func;
+     &warn.experimental.func;
+
+    <para>
+     <function>PDO::errorInfo</function> returns an array of error information
+     about the last operation performed by this database handle. The array
+     consists of the following fields:
+     <informaltable>
+      <tgroup cols='2'>
+       <thead>
+       <row>
+        <entry>Element</entry>
+        <entry>Information</entry>
+       </row>
+       </thead>
+       <tbody>
+       <row>
+        <entry>0</entry>
+        <entry>Generic PDO error code corresponding to one of the
+        <literal>PDO_ERR_*</literal> constants.</entry>
+       </row>
+       <row>
+        <entry>1</entry>
+        <entry>Driver-specific error code.</entry>
+       </row>
+       <row>
+        <entry>2</entry>
+        <entry>Driver-specific error message.</entry>
+       </row>
+       </tbody>
+      </tgroup>
+     </informaltable>
+    </para>
+
+    <para>
+     <function>PDO::errorInfo</function> only retrieves error information
+     for operations performed directly on the database handle. If you create
+     a PDOStatement object through <function>PDO::prepare</function> or
+     <function>PDO::query</function> and invoke an error on the statement
+     handle, <function>PDO::errorInfo</function> will insert an error code
+     of <literal>PDO_ERR_NONE</literal> into the first element of the returned
+     array. You must call <function>PDOStatement::errorInfo</function> to
+     return the error information for an operation performed on a particular
+     statement handle.
+    </para>
+
+    <example><title>Displaying errorInfo() fields for a PDO_ODBC connection to 
a DB2 database</title>
+     <programlisting role="php">
+<![CDATA[
+<?php
+/* Provoke an error -- the BONES table does not exist */
+$dbh->exec("INSERT INTO bones(skull) VALUES ('reagan')");
+
+$arr = $dbh->errorInfo();
+if ($arr[0] == PDO_ERR_NOT_FOUND) {
+    echo "Error: a requested database object does not exist.\n";
+    printf("Driver-specific error code: %d\n", $arr[1]);
+    printf("Driver-specific message: [%s]\n", $arr[2]);
+}
+?>
+]]>
+     </programlisting>
+    </example>
+    &example.outputs;
+    <screen>
+<![CDATA[
+Error: a requested database object does not exist.
+Driver-specific error code: -204
+Driver-specific message: [SQLExecute: -204 [IBM][CLI Driver][DB2/NT]
+SQL0204N  "DB2INST1.BONES" is an undefined name.  SQLSTATE=42704
+ [SQL State 42S02]  (..\pecl\pdo_odbc\odbc_stmt.c:80)]
+]]>
+    </screen>
+
 
    </refsect1>
   </refentry>

Reply via email to