2004-11-10 22:21:24 +00:00
|
|
|
<?xml version='1.0' encoding='iso-8859-1'?>
|
2004-11-26 20:12:46 +00:00
|
|
|
<!-- $Revision: 1.2 $ -->
|
2004-11-10 22:21:24 +00:00
|
|
|
<!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. -->
|
|
|
|
<refentry id="function.PDO-errorCode">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>PDO::errorCode</refname>
|
|
|
|
<refpurpose>
|
|
|
|
Fetch the error code associated with the last operation on the database handle
|
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>int</type><methodname>PDO::errorCode</methodname>
|
|
|
|
<void/>
|
|
|
|
</methodsynopsis>
|
|
|
|
|
2004-11-26 20:12:46 +00:00
|
|
|
&warn.experimental.func;
|
|
|
|
<para>
|
|
|
|
Returns an integer value that maps to the generic error categories
|
|
|
|
defined in the <literal>PDO_ERR_*</literal> set of constants.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<function>PDO::errorCode</function> only retrieves error codes for operations
|
|
|
|
performed directly on the database handle. If you create a PDOStatement
|
|
|
|
object through <function>PDO::prepare</function> or
|
|
|
|
<function>PDO::query</function> and invoke an error on the statement
|
|
|
|
handle, <function>PDO::errorCode</function> will return
|
|
|
|
<literal>PDO_ERR_NONE</literal>. You must call
|
|
|
|
<function>PDOStatement::errorCode</function> to return the error
|
|
|
|
code for an operation performed on a particular statement handle.
|
|
|
|
</para>
|
|
|
|
<example><title>Determining which category of error occurred</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
/* Provoke an error -- the BONES table does not exist */
|
|
|
|
$dbh->exec("INSERT INTO bones(skull) VALUES ('reagan')");
|
|
|
|
|
|
|
|
echo "\nPDO::errorCode(): ";
|
|
|
|
switch ($dbh->errorCode()) {
|
|
|
|
case PDO_ERR_NONE:
|
|
|
|
echo "No error!\n";
|
|
|
|
break;
|
|
|
|
case PDO_ERR_CANT_MAP:
|
|
|
|
echo "Error: Unable to map data types between database and PHP.\n";
|
|
|
|
break;
|
|
|
|
case PDO_ERR_SYNTAX:
|
|
|
|
echo "Error: incorrect syntax\n";
|
|
|
|
break;
|
|
|
|
case PDO_ERR_CONSTRAINT:
|
|
|
|
echo "Error: The request would violate a constraint.\n";
|
|
|
|
break;
|
|
|
|
case PDO_ERR_NOT_FOUND:
|
|
|
|
echo "Error: The object could not be found.\n";
|
|
|
|
break;
|
|
|
|
case PDO_ERR_ALREADY_EXISTS:
|
|
|
|
echo "Error: The object already exists.\n";
|
|
|
|
break;
|
|
|
|
case PDO_ERR_NOT_IMPLEMENTED:
|
|
|
|
echo "Error: The requested function is not implemented.\n";
|
|
|
|
break;
|
|
|
|
case PDO_ERR_MISMATCH:
|
|
|
|
echo "Error: mismatch\n";
|
|
|
|
break;
|
|
|
|
case PDO_ERR_TRUNCATED:
|
|
|
|
echo "Error: The value was truncated because the input value was longer
|
|
|
|
than the maximum column length.\n";
|
|
|
|
break;
|
|
|
|
case PDO_ERR_DISCONNECTED:
|
|
|
|
echo "Error: The connection to the requested database has been closed.\n";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
&example.outputs;
|
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
|
|
|
PDO::errorCode(): Error: The object could not be found.
|
|
|
|
]]>
|
|
|
|
</screen>
|
2004-11-10 22:21:24 +00:00
|
|
|
|
|
|
|
</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
|
|
|
|
-->
|