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

From: Date: Wed, 21 Sep 2005 21:13:24 +0000
Subject: #34235 [Asn->Bgs]: Can't override execute(), can't call own Methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-85395@lists.php.net to get a copy of this message
ID: 34235 Updated by: sniper@php.net Reported By: christian dot mueller at dfpx dot de -Status: Assigned +Status: Bogus Bug Type: PDO related Operating System: * PHP Version: 5CVS-2005-09-16 (snap) Assigned To: helly New Comment: Bogused in favor of #34590 Previous Comments: ------------------------------------------------------------------------ [2005-09-21 12:43:30] sniper@php.net Marcus, look above.. ------------------------------------------------------------------------ [2005-09-21 12:29:59] christian dot mueller at dfpx dot de The code you use does work, ok. But it has nothing to do with the Bug. Please use the "Reproduce code". ------------------------------------------------------------------------ [2005-09-21 11:50:59] helly@php.net Works in php 5.1: php -r 'class T extends PDO{function exec(){var_dump("myexec");}function f(){}}$o=new T("sqlite::memory:");$o->exec();ReflectionClass::export("T");' PDO doesn't support 5.0 atm. ------------------------------------------------------------------------ [2005-08-24 20:22:46] volka at cs dot tu-berlin dot de method_exists() returning true but the actual call failing is bewildering to say the least --8<---8<--- <?php class MTFrame_DB_PDOStatement extends PDOStatement { public function execute() { return; } public function foo() { return; } } class MTFrame_DB_PDO extends PDO { function prepare($sql) { return parent::prepare($sql, array(PDO_ATTR_STATEMENT_CLASS=>array('MTFrame_DB_PDOStatement'))); } } $m = new MTFrame_DB_PDO('sqlite:mydb.sq3'); $stmt = $m->prepare("SELECT COUNT(*) FROM sqlite_master WHERE type='table'"); if ( method_exists($stmt, 'foo') ) $stmt->foo(); else echo 'no such method'; ?> -->8--->8--- ------------------------------------------------------------------------ [2005-08-24 18:13:11] christian dot mueller at dfpx dot de 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. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/34235 -- Edit this bug report at http://bugs.php.net/?id=34235&edit=1

« previous php.bugs (#85395) next »