#34235 [Bgs->Opn]: Can't override execute(), can't call own Methods

From: Date: Wed, 24 Aug 2005 16:13:12 +0000
Subject: #34235 [Bgs->Opn]: Can't override execute(), can't call own Methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-83949@lists.php.net to get a copy of this message
ID: 34235 User updated by: christian dot mueller at dfpx dot de Reported By: christian dot mueller at dfpx dot de -Status: Bogus +Status: Open Bug Type: PDO related Operating System: WinXp Pro PHP Version: 5CVS-2005-08-24 (snap) New Comment: The manual (or further sources) does not state, that PDOStatement::execute() can't be overridden or that PDO::prepare() returns a somewhat castrated object. var_dump($stmt) identifies $stmt as of MTFrame_DB_PDOStatement, just as in my "reproduce code". But the object lacks method foo(). Better said, the object acts, as if it was a plain PDOStatement. This is no expected, please correct me. Previous Comments: ------------------------------------------------------------------------ [2005-08-24 16:15:14] sniper@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php ------------------------------------------------------------------------ [2005-08-24 15:59:14] christian dot mueller at dfpx dot de Description: ------------ When i try to override PDO_Statement::execute(), my Method is ignored completly. When i try to implement ::foo() in my extending class, PHP states it is undefined. Reproduce code: --------------- <?php class MTFrame_DB_PDOStatement extends PDOStatement { public function execute() { throw new Exception(); // Nothing happens, i'm ignored } public function foo() { throw new Exception(); // i do not exist? } } class MTFrame_DB_PDO extends PDO { function prepare($sql) { return parent::prepare($sql, array(PDO_ATTR_STATEMENT_CLASS=>array('MTFrame_DB_PDOStatement'))); } function query($sql) { $stmt = parent::prepare($sql, array(PDO_ATTR_STATEMENT_CLASS=>array('MTFrame_DB_PDOStatement'))); $stmt->foo(); return $stmt; } } ?> Actual result: -------------- MTFrame_DB_PDOStatement::execute() gets ignored. calling ::foo() produces: Call to undefined method MTFrame_DB_PDOStatement::foo() ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34235&edit=1

« previous php.bugs (#83949) next »