|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34235 Can't override execute(), can't call own Methods
Submitted: 2005-08-24 15:59 UTC Modified: 2005-09-21 23:13 UTC
Avg. Score:4.0 ± 1.4
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (100.0%)
From: christian dot mueller at dfpx dot de Assigned: helly
Status: Not a bug Package: PDO related
PHP Version: 5CVS-2005-09-16 (snap) OS: *
Private report: No CVE-ID:
 [2005-08-24 15:59 UTC] christian dot mueller at dfpx dot de
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:

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')));
        return $stmt;


Actual result:
MTFrame_DB_PDOStatement::execute() gets ignored.

calling ::foo() produces:
Call to undefined method MTFrame_DB_PDOStatement::foo() 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-24 18:13 UTC] 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.
 [2005-09-21 23:13 UTC]
Bogused in favor of #34590

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Mon Nov 30 02:01:32 2015 UTC