php.net |  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
Votes:3
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 (profile)
Status: Not a bug Package: PDO related
PHP Version: 5CVS-2005-09-16 (snap) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: christian dot mueller at dfpx dot de
New email:
PHP Version: OS:

 

 [2005-08-24 15:59 UTC] 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() 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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] sniper@php.net
Bogused in favor of #34590

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC