php.net |  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
 [2007-03-21 08:50 UTC] alex at amiran dot it
Description:
------------
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();
print_r($a);
print_r($b);


Expected result:
----------------
CA Object
(
     [a] => 1
)


CB Object
(
     [b] => 2
)


Actual result:
--------------
CB Object
(
     [b] => 2
)


CB Object
(
     [b] => 2
)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-19 14:04 UTC] mj@php.net
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 http://snaps.php.net/?
 [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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC