xref: /PHP-5.6/ext/pdo_mysql/tests/bug63176.phpt (revision cfb1ffb4)
1--TEST--
2Bug #63176 (Segmentation fault when instantiate 2 persistent PDO to the same db server)
3--SKIPIF--
4<?php
5require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
6require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7MySQLPDOTest::skip();
8?>
9--FILE--
10<?php
11require(dirname(__FILE__). DIRECTORY_SEPARATOR . 'config.inc');
12class PDO2 extends PDO {
13	protected $transLevel;
14}
15
16class PDO3 extends PDO {
17	protected $tomato;
18}
19
20
21class ModelA {
22	public function __construct($h) {
23		var_dump($h);
24		if ($h) {
25			$this->db = new PDO2(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true));
26		} else {
27			$this->db = new PDO3(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true));
28		}
29		$this->db->query('SELECT 1')->fetchAll();
30	}
31}
32
33$a = new ModelA(true);
34$b = new ModelA(false);
35
36var_dump($a);
37var_dump($b);
38--EXPECTF--
39bool(true)
40bool(false)
41object(ModelA)#%d (1) {
42  ["db"]=>
43  object(PDO2)#%d (1) {
44    ["transLevel":protected]=>
45    NULL
46  }
47}
48object(ModelA)#%d (1) {
49  ["db"]=>
50  object(PDO2)#%d (1) {
51    ["transLevel":protected]=>
52    NULL
53  }
54}
55