[PDO] unexpected behaviour

From: Date: Sat, 09 Jul 2005 10:32:35 +0000
Subject: [PDO] unexpected behaviour
Groups: php.db 
Request: Send a blank email to php-db+get-39919@lists.php.net to get a copy of this message
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

« previous php.db (#39919) next »