ID: 49268 Updated by: scott...@php.net Reported By: face at dfhu dot org -Status: Open +Status: Bogus Bug Type: SQLite related Operating System: Ubuntu PHP Version: 5.2.6-2ubuntu4.2 New Comment:
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. This was fixed in 5.3.0 already, see bug #42443 Previous Comments: ------------------------------------------------------------------------ [2009-08-15 15:38:13] face at dfhu dot org The version number was not accurate. 5.2.6-2ubuntu4.2 is the version as shown by phpinfo(); ------------------------------------------------------------------------ [2009-08-15 15:24:54] face at dfhu dot org Description: ------------ PDO::Execute quotes integers even though this will cause problems in SQLite. SQLite has type affinity and sometimes requires hard checks. that is "(product_id) VALUES ('1')" is NOT the same as "(product_id) VALUES (1)"; Thanks! -- Victory http://dfhu.org/blog/ Reproduce code: --------------- $pdo=new PDO("sqlite:./db/sales.sqlite"); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql=" CREATE TABLE IF NOT EXISTS sales ( product_id INT CHECK(typeof(product_id) = 'integer') )"; $pdo->query($sql); $sql=" INSERT INTO sales (product_id) VALUES (:product_id)"; $statement=$pdo->prepare($sql); // this will throw a integrity constraint error $statement->execute(Array(":product_id"=>1)); Expected result: ---------------- I do not expect to see an exception thrown, i expect PDO::execute() to not quote integers in SQLite. Thus there should be no output. Actual result: -------------- Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 19 constraint failed' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49268&edit=1