note 72537 deleted from pdo.query by sobak

From: Date: Fri, 02 Dec 2016 05:58:04 +0000
Subject: note 72537 deleted from pdo.query by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207935@lists.php.net to get a copy of this message
Note Submitter: jonmsawyer at gmail dot com ---- @ dozoyousan at gmail dot com > 03-May-2006 05:26 > > When query() fails, the boolean false is returned. > > I think that is "Silent Mode". > If that set attribute ErrorMode "Exception Mode" > then that throw PDOException. > $pdoObj = new PDO( $dsn, $user, $pass ); > $pdoObj->setAttribute("PDO::ATTR_ERRMODE", > PDO::ERRMODE_EXCEPTION); What you say is correct, however, your PHP code is incorrect: <?php // This is fine $pdoObj = new PDO( $dsn, $user, $pass ); // This line is wrong $pdoObj->setAttribute("PDO::ATTR_ERRMODE", PDO::ERRMODE_EXCEPTION); // It should be: $pdoObj->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Parameter 1 should not be in quotes. PHP interprets // that as a string. Instead, internally, its represented // as type LONG INT. Try it :) ?> Hope this helps. Cheers.

« previous php.notes (#207935) next »