Add warning about not abusing the return value of PDO::exec.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@187114 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Dan Scott 2005-05-27 18:23:15 +00:00
parent 686df2bfc9
commit 4295850f9b

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- Generated by xml_proto.php v2.2. Found in /scripts directory of phpdoc. -->
<refentry id="function.PDO-exec">
<refnamediv>
@ -54,6 +54,25 @@
or deleted by the SQL statement you issued. If no rows were affected,
<function>PDO::exec</function> returns <literal>0</literal>.
</para>
<warning>
<para>
Do not rely on the return value as an indicator of success. The following
example incorrectly relies on the return value of
<function>PDO::exec</function>:
<programlisting role="php">
<![CDATA[
<?php
$db->exec() or die($db->errorInfo());
?>
]]>
</programlisting>
The previous example is incorrect because the SQL statement may
legitimately return 0 affected rows, and <function>die</function> does
not distinguish between <literal>0</literal> and &false;.
</para>
</warning>
</refsect1>
<refsect1 role="examples">