php-doc-en/reference/pdo/functions/PDO-errorCode.xml
Hannes Magnusson c030e2adf7 Upgrade to DocBook5:
- All id attributes are now xml:id
 - Add docbook namespace to all root elements
 - Replace <ulink /> with <link xlink:href />
 - Minor markup fixes here and there


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@238160 c90b9560-bf6c-de11-be94-00142212c4b1
2007-06-20 22:25:43 +00:00

103 lines
3.1 KiB
XML

<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.10 $ -->
<refentry xml:id="function.PDO-errorCode" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>PDO->errorCode()</refname>
<refpurpose>
Fetch the SQLSTATE associated with the last operation on the database handle
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<classsynopsis>
<ooclass><classname>PDO</classname></ooclass>
<methodsynopsis>
<type>string</type><methodname>errorCode</methodname>
<void/>
</methodsynopsis>
</classsynopsis>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a SQLSTATE, a five-character alphanumeric identifier defined in
the ANSI SQL-92 standard. Briefly, an SQLSTATE consists of a
two-character class value followed by a three-character subclass value. A
class value of 01 indicates a warning and is accompanied by a return code
of SQL_SUCCESS_WITH_INFO. Class values other than '01', except for the
class 'IM', indicate an error. The class 'IM' is specific to warnings
and errors that derive from the implementation of PDO (or perhaps ODBC,
if you're using the ODBC driver) itself. The subclass value '000' in any
class indicates that there is no subclass for that SQLSTATE.
</para>
<para>
<xref linkend="function.PDO-errorCode" /> only retrieves error codes for operations
performed directly on the database handle. If you create a PDOStatement
object through <xref linkend="function.PDO-prepare" /> or
<xref linkend="function.PDO-query" /> and invoke an error on the statement
handle, <xref linkend="function.PDO-errorCode" /> will not reflect that error.
You must call <xref linkend="function.PDOStatement-errorCode" /> to return the error
code for an operation performed on a particular statement handle.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example><title>Retrieving a SQLSTATE code</title>
<programlisting role="php">
<![CDATA[
<?php
/* Provoke an error -- the BONES table does not exist */
$dbh->exec("INSERT INTO bones(skull) VALUES ('lucy')");
echo "\nPDO::errorCode(): ";
print $dbh->errorCode();
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
PDO::errorCode(): 42S02
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><xref linkend="function.PDO-errorInfo" /></member>
<member><xref linkend="function.PDOStatement-errorCode" /></member>
<member><xref linkend="function.PDOStatement-errorInfo" /></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- 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
-->