mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-18 18:08:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@197576 c90b9560-bf6c-de11-be94-00142212c4b1
74 lines
2.7 KiB
XML
74 lines
2.7 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.2 $ -->
|
|
<sect1 id="internals.pdo.error-handling">
|
|
<title>Error handling</title>
|
|
<para>
|
|
Error handling is implemented using a hand-shaking protocol between
|
|
PDO and the database driver code. The database driver code
|
|
signals PDO than an error has occurred via a failure
|
|
(<literal>0</literal>) return from any of the interface functions. If a zero
|
|
is returned, the field <parameter>error_code</parameter> in the control block appropriate to the
|
|
context (either the pdo_dbh_t or pdo_stmt_t block). In practice, it is
|
|
probably a good idea to set the field in both blocks to the same value to
|
|
ensure the correct one is getting used.
|
|
</para>
|
|
|
|
<para>
|
|
The error_mode field is a six-byte field containing a 5 character ASCIIZ
|
|
SQLSTATE identifier code. This code drives the error message process. The
|
|
SQLSTATE code is used to look up an error message in the internal PDO error
|
|
message table (see pdo_sqlstate.c for a list of error codes and their
|
|
messages). If the code is not known to PDO, a default
|
|
<quote>Unknown Message</quote> value will be used.
|
|
</para>
|
|
|
|
<para>
|
|
In addition to the SQLSTATE code and error message, PDO will
|
|
call the driver-specific fetch_err() routine to obtain supplemental data
|
|
for the particular error condition. This routine is passed an array into
|
|
which the driver may place additional information. This array has slot
|
|
positions assigned to particular types of supplemental info:
|
|
</para>
|
|
|
|
<orderedlist>
|
|
<listitem>
|
|
<para>
|
|
A native error code. This will frequently be an error code obtained
|
|
from the database API.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
A descriptive string. This string can contain anything additional
|
|
information related to the failure. Database drivers typically include
|
|
information such as an error message, code location of the failure, and
|
|
any additional descriptive information the driver developer feels
|
|
worthy of inclusion. It is generally a good idea to include all
|
|
diagnostic information obtainable
|
|
from the database interface at the time of the failure. For
|
|
driver-detected errors (such as memory allocation problems), the driver
|
|
developer can define whatever error information that seems appropriate.
|
|
</para>
|
|
</listitem>
|
|
</orderedlist>
|
|
</sect1>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|