mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Describe the errorInfo() array, add example.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@173553 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
74ae6ee964
commit
492aea4f11
1 changed files with 62 additions and 3 deletions
|
@ -1,11 +1,11 @@
|
|||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. -->
|
||||
<refentry id="function.PDOStatement-errorInfo">
|
||||
<refnamediv>
|
||||
<refname>PDOStatement::errorInfo</refname>
|
||||
<refpurpose>
|
||||
Fetch extended error information associated with the last operation on the statement handle
|
||||
Fetch an array of error information associated with the last operation on the statement handle
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
|
@ -15,7 +15,66 @@
|
|||
<void/>
|
||||
</methodsynopsis>
|
||||
|
||||
&warn.undocumented.func;
|
||||
&warn.experimental.func;
|
||||
<para>
|
||||
<function>PDOStatement::errorInfo</function> returns an array of
|
||||
error information about the last operation performed by this
|
||||
statement handle. The array consists of the following fields:
|
||||
<informaltable>
|
||||
<tgroup cols='2'>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Element</entry>
|
||||
<entry>Information</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>0</entry>
|
||||
<entry>Generic PDO error code corresponding to one of the
|
||||
<literal>PDO_ERR_*</literal> constants.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>1</entry>
|
||||
<entry>Driver-specific error code.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>2</entry>
|
||||
<entry>Driver-specific error message.</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</para>
|
||||
|
||||
<example><title>Displaying errorInfo() fields for a PDO_ODBC connection to a DB2 database</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/* Provoke an error -- the BONES table does not exist */
|
||||
$sth = $dbh->prepare('SELECT skull FROM bones');
|
||||
$sth->execute();
|
||||
|
||||
$arr = $sth->errorInfo();
|
||||
if ($arr[0] == PDO_ERR_NOT_FOUND) {
|
||||
echo "Error: a requested database object does not exist.\n";
|
||||
printf("Driver-specific error code: %d\n", $arr[1]);
|
||||
printf("Driver-specific message: [%s]\n", $arr[2]);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Error: a requested database object does not exist.
|
||||
Driver-specific error code: -204
|
||||
Driver-specific message: [SQLExecute: -204 [IBM][CLI Driver][DB2/NT]
|
||||
SQL0204N "DB2INST1.BONES" is an undefined name. SQLSTATE=42704
|
||||
[SQL State 42S02] (..\pecl\pdo_odbc\odbc_stmt.c:80)]
|
||||
]]>
|
||||
</screen>
|
||||
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
|
Loading…
Reference in a new issue