pdo does not thrown errors on simple usage faults

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

 



Hi there,

I have just begun an implementation of the PDO and have noticed an
unusual behaviour.
The following code is supplied as an example to illustrate this. The
main issue here is
that no error is thrown. There is no notice of failure at all for the
second fetch/execute which returns just an empty array.

thanks in advance

meno
<?php
   $dbh = new PDO('mysql:dbname=myDatabase;host=localhost',
'myUserName', 'myPassWord');
   $dbh->setAttribute(PDO_ATTR_ERRMODE,PDO_ERRMODE_WARNING);
   $sql = 'SELECT id  FROM my_table WHERE id > :id limit 0,10';
   $sql2 = 'SELECT id, title FROM my_other_table WHERE id > :id limit 0,10';
   $stmt1 = $dbh->prepare($sql);
   $stmt2 = $dbh->prepare($sql2);
   $stmt1->execute(array(':id'=>4));
   while($row = $stmt1->fetch()){
       print_r($row);
       $stmt2->execute(array(':id'=>2));
       $row = $stmt2->fetchAll();
       print_r($row);
       print_r($dbh->errorInfo());
   }
?>

-- 
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