php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38394 PDO inconsistency on some warnings
Submitted: 2006-08-09 07:52 UTC Modified: 2006-08-09 14:46 UTC
From: stochnagara at hotmail dot com Assigned:
Status: Closed Package: PDO related
PHP Version: 5.2.0RC1 OS: windows xp
Private report: No CVE-ID: None
 [2006-08-09 07:52 UTC] stochnagara at hotmail dot com
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-09 14:46 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC