|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-12-28 01:39 UTC] xing at mac dot com
Description:
------------
Mysql version 4.1.15
use mysql_pdo with attribute enabled to have it throw exception on all errors:
Reproduce code:
---------------
$st = $db->prepare("select * from test where c = 2 AND (a = :a OR b =
:a)");
$st->execute(array(":a" => 2));
Expected result:
----------------
Rows matching where a == 2 or b == 2 OR an exception if pdo doesn't support having the same variable appear more than once in a prepared query.
Actual result:
--------------
0 row result regardless of what's in the database. No error or
exceptions from pdo. Everything points to successful query when nothing has been executed.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 20:00:01 2025 UTC |
Turns out it's because I did not set the error attribute correctly. Apparently you cannot set it via the construct method. new PDO("mysql:host=1.1.1.1;unix_socket=/tmp/my.sock;dbname=testdb", $USER, $PASS, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ); the above does not work...to set the error mode attribute..had to use the below after pdo connection is made. setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);