Edit report at https://bugs.php.net/bug.php?id=53970&edit=1

 ID:                 53970
 Updated by:         u...@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

Reply via email to