downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/internals2.pdo.error-handling.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/internals2.pdo.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'internals2.pdo.error-handling.php',
   
1 => 'Error handling',
  ),
 
'up' =>
  array (
   
0 => 'internals2.pdo.php',
   
1 => 'PDO Driver How-To',
  ),
 
'prev' =>
  array (
   
0 => 'internals2.pdo.constants.php',
   
1 => 'Constants',
  ),
 
'next' =>
  array (
   
0 => 'internals2.faq.php',
   
1 => 'Extension FAQs',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="internals2.pdo.error-handling" class="sect1">
 <h2 class="title">Error handling</h2>
 <p class="para">
  Error handling is implemented using a hand-shaking protocol between
  PDO and the database driver code. The database driver code
  signals PDO that an error has occurred via a failure
  (<i>0</i>) return from any of the interface functions. If a zero
  is returned, set the field <i><tt class="parameter">error_code</tt></i>
 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.
 </p>

 <p class="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
  "<span class="quote">Unknown Message</span>" value will be used.
 </p>

 <p class="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:
 </p>

 <ol type="1">
  <li class="listitem">
   <p class="para">
    A native error code. This will frequently be an error code obtained
    from the database API.
   </p>
  </li>
  <li class="listitem">
   <p class="para">
    A descriptive string. This string can contain any 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.
   </p>
  </li>
 </ol>
</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites