ID: 49268 User updated by: face at dfhu dot org Reported By: face at dfhu dot org Status: Open Bug Type: SQLite related Operating System: Ubuntu -PHP Version: 5.3.0 +PHP Version: 5.2.6-2ubuntu4.2 New Comment:
The version number was not accurate. 5.2.6-2ubuntu4.2 is the version as shown by phpinfo(); Previous Comments: ------------------------------------------------------------------------ [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