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/pdo.errorinfo.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/class.pdo.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'pdo.errorinfo.php',
   
1 => 'PDO::errorInfo',
  ),
 
'up' =>
  array (
   
0 => 'class.pdo.php',
   
1 => 'The PDO class',
  ),
 
'prev' =>
  array (
   
0 => 'pdo.errorcode.php',
   
1 => 'PDO::errorCode',
  ),
 
'next' =>
  array (
   
0 => 'pdo.exec.php',
   
1 => 'PDO::exec',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="pdo.errorinfo" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PDO::errorInfo</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PECL pdo &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">PDO::errorInfo</span> &mdash; <span class="dc-title">
   Fetch extended error information associated with the last operation on the database handle
  </span></p>

 </div>
 <a name="pdo.errorinfo.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><b>PDO::errorInfo</b></span>
    ( <span class="methodparam">void</span>
   )</div>


 </div>


 <a name="pdo.errorinfo.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   <b>PDO::errorInfo()</b> returns an array of error information
   about the last operation performed by this database handle. The array
   consists of the following fields:
   </p><table class="doctable informaltable">
   
     <thead valign="middle">
      <tr valign="middle">
       <th>Element</th>
       <th>Information</th>
      </tr>

     </thead>

     <tbody valign="middle" class="tbody">
      <tr valign="middle">
       <td align="left">0</td>
       <td align="left">SQLSTATE error code (a five characters alphanumeric identifier defined
               in the ANSI SQL standard).</td>
      </tr>

      <tr valign="middle">
       <td align="left">1</td>
       <td align="left">Driver-specific error code.</td>
      </tr>

      <tr valign="middle">
       <td align="left">2</td>
       <td align="left">Driver-specific error message.</td>
      </tr>

     </tbody>
   
   </table>
<p>
  </p>

  <blockquote><p><b class="note">Note</b>:
  
    If the SQLSTATE error code is not set or there is no driver-specific
    error, the elements following element 0 will be set to <b><tt class="constant">NULL</tt></b>.
    <br />
  </p></blockquote>

  <p class="para">
   <b>PDO::errorInfo()</b> only retrieves error information for
   operations performed directly on the database handle. If you create a
   PDOStatement object through <a href="pdo.prepare.php" class="function">PDO::prepare()</a> or
   <a href="pdo.query.php" class="function">PDO::query()</a> and invoke an error on the statement
   handle, <b>PDO::errorInfo()</b> will not reflect the error
   from the statement handle. You must call
   <a href="pdostatement.errorinfo.php" class="function">PDOStatement::errorInfo()</a> to return the error
   information for an operation performed on a particular statement handle.
  </p>
 </div>


 <a name="pdo.errorinfo.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example"><p><b>Example #1 Displaying errorInfo() fields for a PDO_ODBC connection to a DB2 database</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;Provoke&nbsp;an&nbsp;error&nbsp;--&nbsp;bogus&nbsp;SQL&nbsp;syntax&nbsp;*/<br /></span><span style="color: #0000BB">$stmt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prepare</span><span style="color: #007700">(</span><span style="color: #DD0000">'bogus&nbsp;sql'</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"\nPDO::errorInfo():\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">errorInfo</span><span style="color: #007700">());<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents para"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
PDO::errorInfo():
Array
(
    [0] =&gt; HY000
    [1] =&gt; 1
    [2] =&gt; near &quot;bogus&quot;: syntax error
)
</pre></div>
    </div>
   </div><p>
  </p>
 </div>


 <a name="pdo.errorinfo.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="pdo.errorcode.php" class="function" rel="rdfs-seeAlso">PDO::errorCode()</a> - Fetch the SQLSTATE associated with the last operation on the database handle</li>
    <li class="member"><a href="pdostatement.errorcode.php" class="function" rel="rdfs-seeAlso">PDOStatement::errorCode()</a> - Fetch the SQLSTATE associated with the last operation on the statement handle</li>
    <li class="member"><a href="pdostatement.errorinfo.php" class="function" rel="rdfs-seeAlso">PDOStatement::errorInfo()</a> - Fetch extended error information associated with the last operation on the statement handle</li>
   </ul><p>
  </p>
 </div>



</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites