Bug #53970 [Opn->Nab]: PDOStatement::execute returns TRUE even when sql statement is not executed
| From: | uw@php.net | Date: | Fri, 04 May 2012 16:14:44 +0000 |
| Subject: | Bug #53970 [Opn->Nab]: PDOStatement::execute returns TRUE even when sql statement is not executed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-170182@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=53970&edit=1
ID: 53970
Updated by: uw@php.net
Reported by: lopez at freshsite dot de
Summary: PDOStatement::execute returns TRUE even when sql
statement is not executed
-Status: Open
+Status: Not a bug
Type: Bug
Package: PDO related
Operating System: Windows
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
There's no error when using MySQL defaults, just a warning.
See http://dev.mysql.com/doc/refman/5.6/en/server-sql-mode.html
and set sql_mode accordingly to get an error.
Previous Comments:
------------------------------------------------------------------------
[2011-02-09 13:44:08] lopez at freshsite dot de
I recognized, that the error was different, but the expected result is same.
The sql statement tried to insert a too long string (6 chars) into a too small field =>
varchar(2).
However, the execute function should return FALSE, but it doesn't !
------------------------------------------------------------------------
[2011-02-09 12:04:13] lopez at freshsite dot de
Description:
------------
I recognized, that the return value stay TRUE, even if the sql statement could not be executed
correctly.
Test script:
---------------
Example:
$sth = $this->db->prepare("REPLACE INTO test
SET bar = :foo);
$error = $sth->execute(array('foo' => 'bar'));
/*
$error will be TRUE, because sql is correct and sent.
However, if the mysql user has not the rights (INSERT,DELETE) to do this, the statement will be not
executed at all without error message.
So, don't rely on the returning value until this is fixed!
Expected result:
----------------
$error should be FALSE
Actual result:
--------------
$error is TRUE
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=53970&edit=1