|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-08-09 14:46 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Description: ------------ PDO behaves strangely with some incorrect calls of 'execute'. The first $s->execute is working as expected. The second one does not do anything. The third one does not do anything which is not expected. The fourth one generates as warning as expected. So problem 1 is that the second execute does not generate a warning and also causes the third execute not to get executed. If we set PDO::ATTR_ERRMODE to be PDO::ERRMODE_EXCEPTION, we see that the second execute generates a "General error: 25 bind or column index out of range" exception which is ok. And if we set PDO::ATTR_ERRMODE to be PDO::ERRMODE_WARNING, then the situation gets more and more mysterious: Now the second execute correctly generates a warning but after that the third one which is correct, also generates a warning which is not correct at all. Reproduce code: --------------- <? $q = new PDO ("sqlite::memory:"); //$q->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //$q->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $q->exec ("CREATE TABLE test (a,b,c)"); $s=$q->prepare ("INSERT INTO test (a,b,c) VALUES (:a,:b,:c)"); $s->execute(array ('a' => 1, 'b' => 2, 'c' => 3)); $s->execute(array ('a' => 5, 'b' => 6, 'c' => 7, 'd' => 8)); $s->execute(array ('a' => 9, 'b' => 10, 'c' => 11)); $s->execute((object)array ('a' => 1, 'b' => 2, 'c' => 3)); var_dump($q->query("SELECT * FROM test")->fetchAll(PDO::FETCH_ASSOC)); ?> Expected result: ---------------- see description Actual result: -------------- see description