note 73567 deleted from ref.pdo by nlopess

From: Date: Thu, 01 Mar 2007 19:08:27 +0000
Subject: note 73567 deleted from ref.pdo by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123991@lists.php.net to get a copy of this message
Note Submitter: ---- If you intend on extending PDOStatement and your using setAttribute(PDO::ATTR_STATEMENT_CLASS, ...) you must override the __construct() of your PDOStatement class. failure to do so will result in an error on any PDO::query() call. Warning: PDO::query() [function.PDO-query]: SQLSTATE[HY000]: General error: user-supplied statement does not accept constructor arguments Here is a minimum PDO and PDOStatement class <?php class Database extends PDO { function __construct($dsn, $username="", $password="", $driver_options=array()) { parent::__construct($dsn,$username,$password, $driver_options); $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DBStatement', array($this))); } } class DBStatement extends PDOStatement { public $dbh; protected function __construct($dbh) { $this->dbh = $dbh; } } ?>

« previous php.notes (#123991) next »