For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > May 2005 > cvs: phpdoc /en/reference/pdo/functions PDO-exec.xml









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cvs: phpdoc /en/reference/pdo/functions PDO-exec.xml
Dan Scott

2005-05-27, 8:55 pm

dbs Fri May 27 14:23:16 2005 EDT

Modified files:
/phpdoc/en/reference/pdo/functions PDO-exec.xml
Log:
Add warning about not abusing the return value of PDO::exec.


http://cvs.php.net/diff.php/phpdoc/...1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/pdo/functions/PDO-exec.xml
diff -u phpdoc/en/reference/pdo/functions/PDO-exec.xml:1.3 phpdoc/en/reference/pdo/functions/PDO-exec.xml:1.4
--- phpdoc/en/reference/pdo/functions/PDO-exec.xml:1.3 Mon Jan 17 22:16:39 2005
+++ phpdoc/en/reference/pdo/functions/PDO-exec.xml Fri May 27 14:23:15 2005
@@ -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">
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com