xref: /php-src/ext/pdo_mysql/tests/gh16314.phpt (revision 5faef8e6)
1--TEST--
2GH-16314 "Pdo\Mysql object is uninitialized" when opening a persistent connection
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once __DIR__ . '/inc/mysql_pdo_test.inc';
8MySQLPDOTest::skip();
9?>
10--FILE--
11<?php
12require_once __DIR__ . '/inc/mysql_pdo_test.inc';
13
14$attr = [
15    PDO::ATTR_PERSISTENT => true,
16    PDO::ATTR_STRINGIFY_FETCHES => true,
17];
18
19$pdo = MySQLPDOTest::factory(Pdo\Mysql::class, null, $attr, false);
20var_dump($pdo->query('SELECT 1;')->fetchAll());
21
22$pdo = MySQLPDOTest::factory(Pdo\Mysql::class, null, $attr, true);
23var_dump($pdo->query('SELECT 1;')->fetchAll());
24
25$pdo = MySQLPDOTest::factory(Pdo::class, null, $attr, false);
26var_dump($pdo->query('SELECT 1;')->fetchAll());
27
28$pdo = MySQLPDOTest::factory(Pdo::class, null, $attr, true);
29var_dump($pdo->query('SELECT 1;')->fetchAll());
30?>
31--EXPECT--
32array(1) {
33  [0]=>
34  array(2) {
35    [1]=>
36    string(1) "1"
37    [0]=>
38    string(1) "1"
39  }
40}
41array(1) {
42  [0]=>
43  array(2) {
44    [1]=>
45    string(1) "1"
46    [0]=>
47    string(1) "1"
48  }
49}
50array(1) {
51  [0]=>
52  array(2) {
53    [1]=>
54    string(1) "1"
55    [0]=>
56    string(1) "1"
57  }
58}
59array(1) {
60  [0]=>
61  array(2) {
62    [1]=>
63    string(1) "1"
64    [0]=>
65    string(1) "1"
66  }
67}
68