|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57586 Inheriting from PDO breaks classes
Submitted: 2007-03-21 08:50 UTC Modified: 2013-02-18 00:35 UTC
From: alex at amiran dot it Assigned:
Status: No Feedback Package: PDO (PECL)
PHP Version: 5.2.0 OS: various Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
39 - 20 = ?
Subscribe to this entry?

 [2007-03-21 08:50 UTC] alex at amiran dot it
When subclassing PDO from different classes, all the classes become the last instantiated.

This happens in the Debian etch packages (php5 5.2.0-8+etch1) and in CentOS release 4.4 (php5 5.2.0-10 built from fedora SRPM)

Reproduce code:
class CA extends PDO {
  public $a=1;
  public function __construct() {
    parent::__construct("mysql:dbname=dbname", "user", "password",array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'",PDO::ATTR_PERSISTENT => true));

class CB extends PDO {
  public $b=2;
  public function __construct() {
    parent::__construct("mysql:dbname=dbname", "user", "password",array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'",PDO::ATTR_PERSISTENT => true));
$a = new CA();
$b = new CB();

Expected result:
CA Object
     [a] => 1

CB Object
     [b] => 2

Actual result:
CB Object
     [b] => 2

CB Object
     [b] => 2


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-19 14:04 UTC]
Works fine for me with the latest snapshot of PHP 5.2.x using a SQLite driver instead of MySQL.  (I cannot test with MySQL at the moment.) Can you please try for yourself with the latest snapshot from
 [2013-02-18 00:35 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Oct 15 21:03:43 2021 UTC