<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = 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 => 'zh',
  ),
  'this' => 
  array (
    0 => 'pdo.errorinfo.php',
    1 => 'PDO::errorInfo',
    2 => 'Fetch extended error information associated with the last operation on the database handle',
  ),
  'up' => 
  array (
    0 => 'class.pdo.php',
    1 => 'PDO',
  ),
  'prev' => 
  array (
    0 => 'pdo.errorcode.php',
    1 => 'PDO::errorCode',
  ),
  'next' => 
  array (
    0 => 'pdo.exec.php',
    1 => 'PDO::exec',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pdo/pdo/errorinfo.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="pdo.errorinfo" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PDO::errorInfo</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8, 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>
 <div class="refsect1 description" id="refsect1-pdo.errorinfo-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>PDO::errorInfo</strong></span>(): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>


 </div>


 <div class="refsect1 parameters" id="refsect1-pdo.errorinfo-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-pdo.errorinfo-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   <span class="methodname"><strong>PDO::errorInfo()</strong></span> returns an array of error information
   about the last operation performed by this database handle. The array
   consists of at least the following fields:
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Element</th>
       <th>Information</th>
      </tr>

     </thead>

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

      <tr>
       <td>1</td>
       <td>Driver-specific error code.</td>
      </tr>

      <tr>
       <td>2</td>
       <td>Driver-specific error message.</td>
      </tr>

     </tbody>
    
   </table>

  </p>

  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    If the SQLSTATE error code is not set or there is no driver-specific
    error, the elements following element 0 will be set to <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>.
    </p>
  </p></blockquote>

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


 <div class="refsect1 examples" id="refsect1-pdo.errorinfo-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1110"><p><strong>示例 #1 Displaying errorInfo() fields for a PDO_ODBC connection to a DB2 database</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/* Provoke an error -- bogus SQL syntax */<br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </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 sql'</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"\nPDO::errorInfo():\n"</span><span style="color: #007700">;<br />    </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"><p>以上示例会输出:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">PDO::errorInfo():
Array
(
    [0] =&gt; HY000
    [1] =&gt; 1
    [2] =&gt; near &quot;bogus&quot;: syntax error
)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-pdo.errorinfo-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="pdo.errorcode.php" class="methodname" rel="rdfs-seeAlso">PDO::errorCode()</a> - 获取跟数据库句柄上一次操作相关的 SQLSTATE</span></li>
    <li><span class="methodname"><a href="pdostatement.errorcode.php" class="methodname" rel="rdfs-seeAlso">PDOStatement::errorCode()</a> - 获取跟上一次语句句柄操作相关的 SQLSTATE</span></li>
    <li><span class="methodname"><a href="pdostatement.errorinfo.php" class="methodname" rel="rdfs-seeAlso">PDOStatement::errorInfo()</a> - 获取跟上一次语句句柄操作相关的扩展错误信息</span></li>
   </ul>
  </p>
 </div>



</div><?php manual_footer($setup); ?>