Re: Problem with PDO exceptions

From: Date: Sat, 07 Mar 2009 20:55:40 +0000
Subject: Re: Problem with PDO exceptions
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-46053@lists.php.net to get a copy of this message
I think it is a bug. I have seen this happening at work (PDO not throwing exception when executing a query on a non existing table) News on iPhone: http://trk7.com/mob On 08/03/2009, at 6:44 AM, Daniel Carrera <daniel.carrera@theingots.org> wrote:
Hello, I have MySQL 5.1 and PHP 5.2. For some reason PDO is not throwing exceptions when I give it a broken SQL query. For example: try { $stmt = $db->prepare("SELECT * FROM foobar WHERE 1"); } catch(PDOException $e) { error($e->getMessage()); } In this example there is no table called 'foobar', so this should give an error. Yet, it doesn't. Any ideas why that would happen? Possible causes I can think of: 1) PDO decide to "emulate" prepared statements. 2) PDO has some sort of "errors off" setting. 3) My try-catch statement is wrong. I doubt it's (1) because I have MySQL 5.1 and PDO is only supposed to emulate prepared statements for MySQL versions prior to 4.1. And phpinfo says that I'm running pdo_mysql version 5.1.30. Btw, $db->exec() and $db->query() also fail to produce an error when I give them a broken query. That's another reason why I think that the problem is elsewhere. Any ideas? Thank you very much for your help. Best, Daniel. --PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.db (#46053) next »