From 4295850f9bfc4b83490a27e001ae3ded39b8970a Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Fri, 27 May 2005 18:23:15 +0000 Subject: [PATCH] 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 --- reference/pdo/functions/PDO-exec.xml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/reference/pdo/functions/PDO-exec.xml b/reference/pdo/functions/PDO-exec.xml index b7042414be..5afc4bd153 100644 --- a/reference/pdo/functions/PDO-exec.xml +++ b/reference/pdo/functions/PDO-exec.xml @@ -1,5 +1,5 @@ - + @@ -54,6 +54,25 @@ or deleted by the SQL statement you issued. If no rows were affected, PDO::exec returns 0. + + + + Do not rely on the return value as an indicator of success. The following + example incorrectly relies on the return value of + PDO::exec: + +exec() or die($db->errorInfo()); +?> +]]> + + The previous example is incorrect because the SQL statement may + legitimately return 0 affected rows, and die does + not distinguish between 0 and &false;. + + +