xref: /PHP-8.0/ext/pdo/tests/bug_72788.phpt (revision 26dfce7f)
1--TEST--
2PDO Common: Bug #72788 (Invalid memory access when using persistent PDO connection)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo')) die('skip');
6$dir = getenv('REDIR_TEST_DIR');
7if (false == $dir) die('skip no driver');
8require_once $dir . 'pdo_test.inc';
9PDOTest::skip();
10?>
11--FILE--
12<?php
13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
14require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
15
16putenv("PDOTEST_ATTR=" . serialize(array(PDO::ATTR_PERSISTENT => true)));
17
18function test() {
19    $db = PDOTest::factory('PDO', false);
20    $stmt = @$db->query("SELECT 1 FROM TABLE_DOES_NOT_EXIST");
21    if ($stmt === false) {
22        echo "Statement failed as expected\n";
23    }
24}
25
26test();
27test();
28echo "Done";
29?>
30--EXPECT--
31Statement failed as expected
32Statement failed as expected
33Done
34