cvs: peardoc /en/package/database/db db-error.xml

From: Date: Sun, 21 Mar 2004 21:21:41 +0000
Subject: cvs: peardoc /en/package/database/db db-error.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-3050@lists.php.net to get a copy of this message
danielc Sun Mar 21 16:21:41 2004 EDT Modified files: /peardoc/en/package/database/db db-error.xml Log: Explain getCode(). Provide example. http://cvs.php.net/diff.php/peardoc/en/package/database/db/db-error.xml?r1=1.9&r2=1.10&ty=u Index: peardoc/en/package/database/db/db-error.xml diff -u peardoc/en/package/database/db/db-error.xml:1.9 peardoc/en/package/database/db/db-error.xml:1.10 --- peardoc/en/package/database/db/db-error.xml:1.9 Sat Mar 6 00:42:13 2004 +++ peardoc/en/package/database/db/db-error.xml Sun Mar 21 16:21:41 2004 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <refentry id="package.database.db.db-error"> <refnamediv> <refname><classname>DB_Error</classname></refname> @@ -17,10 +17,42 @@ are consistent between each DBMS. </para> <para> + The error code integers returned by <function>DB_Error::getCode</function> + are also consistent between each DBMS. The integers returned are based + on the <constant>DB_ERROR_*</constant> constants defined in + <filename>DB.php</filename>. + </para> + <para> <function>DB_Error::getDebugInfo</function> and <function>DB_Error::getUserInfo</function> return complete native DBMS error reports. </para> + + <example> + <title>Trapping errors and determining what happened</title> + <programlisting role="php"> + <![CDATA[ +<?php +require_once 'DB.php'; + +$db =& DB::connect('pgsql://wronguser:badpw@localhost/thedb'); +if (DB::isError($db)) { + /* + * This is not what you would really want to do in + * your program. It merely demonstrates what kinds + * of data you can get back from error objects. + */ + echo 'Standard Message: ' . $db->getMessage() . "\n"; + echo 'Standard Code: ' . $db->getCode() . "\n"; + echo 'DBMS/User Message: ' . $db->getUserInfo() . "\n"; + echo 'DBMS/Debug Message: ' . $db->getDebugInfo() . "\n"; + exit; +} +?> + ]]> + </programlisting> + </example> + </refsect1> </refentry>

« previous php.pear.doc (#3050) next »