|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-01-05 06:22 UTC] gpkappos at ucy dot ac dot cy
Description:
------------
When extending PDO, if you use persistent connections you can only create instances of the first object that uses the connection.
In the example below the constructor for B returns an instance of A
Test script:
---------------
class A extends \PDO {
public function __construct()
{
parent::__construct('oci:dbname=//dbserver.example.org:1521/dbserver.example.org;charset=AL32UTF8', 'test', 'testpw', [PDO::ATTR_PERSISTENT => true]);
}
}
class B extends \PDO {
public function __construct()
{
parent::__construct('oci:dbname=//dbserver.example.org:1521/dbserver.example.org;charset=AL32UTF8', 'test', 'testpw', [PDO::ATTR_PERSISTENT => true]);
}
}
$a = new A();
var_dump($a);
$b = new B();
var_dump($b);
Expected result:
----------------
object(A)[1]
object(B)[2]
Actual result:
--------------
object(A)[1]
object(A)[2]
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 23:00:01 2025 UTC |
Hello, thank you for your reply. Here is the script, it uses oracle instant client and an oracle database but no tables are needed, just a connection: <?php class A extends \PDO { public function __construct() { parent::__construct('oci:dbname=//<dbserver1>:1521/<servicename1>;charset=AL32UTF8', 'scott', 'tiger', [PDO::ATTR_PERSISTENT => true]); } } class B extends \PDO { public function __construct() { parent::__construct('oci:dbname=//<dbserver1>:1521/<servicename1>;charset=AL32UTF8', 'scott', 'tiger', [PDO::ATTR_PERSISTENT => true]); } } $a = new A(); var_dump($a); $b = new B(); var_dump($b); ?>