[PDO] unexpected behaviour

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

Yesterday I played with PDO and I ran into an unexpected behaviour.
In the following code, statement 2 is never executed because of a out of sync warning. But if you have exceptions enabled there is no exception thrown and you wonder about the result.
Should a new statement not override an old statement?
Why are there statement objects if I could only execute one statement?
Is this a db driver specific issue or because it's not implemented yet?
For testing I used PHP 5.1.0b2.

<?php
$pdo = new PDO('mysql:dbname=db;host=localhost', 'user', 'password');
$pdo->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_WARNING); # Try in exception mode, too

$stmt_1 = $pdo->prepare('SELECT x FROM table');
$stmt_1->execute();

$stmt_2 = $pdo->prepare('SELECT y FROM table');
$stmt_2->execute();

// Returns nothing !!!
print("Statement2: \n");
while ($row = $stmt_2->fetch(PDO_FETCH_ASSOC)) print_r($row);

print("Statement1: \n");
while ($row = $stmt_1->fetch(PDO_FETCH_ASSOC)) print_r($row);
?>

Greets,
Jochen Vajda

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux