note 73567 added to ref.pdo

From: Date: Thu, 01 Mar 2007 18:57:00 +0000
Subject: note 73567 added to ref.pdo
Groups: php.notes 
Request: Send a blank email to php-notes+get-123989@lists.php.net to get a copy of this message
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; } } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 71.221.247.240 ---- Manual Page -- http://www.php.net/manual/en/ref.pdo.php Edit -- https://master.php.net/note/edit/73567 Del: integrated -- https://master.php.net/note/delete/73567/integrated Del: useless -- https://master.php.net/note/delete/73567/useless Del: bad code -- https://master.php.net/note/delete/73567/bad+code Del: spam -- https://master.php.net/note/delete/73567/spam Del: non-english -- https://master.php.net/note/delete/73567/non-english Del: in docs -- https://master.php.net/note/delete/73567/in+docs Del: other reasons-- https://master.php.net/note/delete/73567 Reject -- https://master.php.net/note/reject/73567 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123989) next »