From:             r dot wilczek at web-appz dot de
Operating system: openSuse 10.3
PHP version:      5.2.5
PHP Bug Type:     PDO related
Bug description:  PDO::prepare() throws PDOException instead of returning FALSE

Description:
------------
Documentation says PDO::prepare() returns FALSE on failure.

But tests with PDO_SQLITE and PDO_MYSQL show that you either get a
PDOException thrown at you or a PDOStatement which cannot be executed.

I am quite surprised, for I upgraded from PHP5.2.0 to PHP5.2.5. In 5.2.0
both drivers threw exceptions on syntax-errors in PDO::prepare().

One could live with exceptions instead of FALSE but it should be done in a
uniform manner of all the drivers.

Reproduce code:
---------------
$pdo = new PDO('mysql:host=localhost;dbname=test',
               'user', 'password',
               array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$stmt = $pdo->prepare('some nonsense');
var_dump($stmt);

$pdo = new PDO('sqlite:/tmp/foo.db',
               'user', 'password',
               array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$stmt = $pdo->prepare('some nonsense');
var_dump($stmt);


Expected result:
----------------
bool(false)
bool(false)

Actual result:
--------------
object(PDOStatement)#2 (1) {
  ["queryString"]=>
  string(13) "some nonsense"
}

Fatal error:  Uncaught exception 'PDOException' with message
'SQLSTATE[HY000]: General error: 1 near "some": syntax error' in
PHPDocument1:5

-- 
Edit bug report at http://bugs.php.net/?id=43443&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43443&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43443&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43443&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43443&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43443&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43443&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43443&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43443&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43443&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43443&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43443&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43443&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43443&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43443&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43443&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43443&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43443&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43443&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43443&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43443&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43443&r=mysqlcfg

Reply via email to