xref: /PHP-8.0/ext/pdo_mysql/tests/bug79872.phpt (revision 288581fa)
1--TEST--
2Bug #79872: Can't execute query with pending result sets
3--SKIPIF--
4<?php
5require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc');
6require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7MySQLPDOTest::skip();
8?>
9--FILE--
10<?php
11require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
12
13$db = MySQLPDOTest::factory();
14$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
15
16$stmt = $db->prepare('SET @foo = 1; SET @bar = 2;');
17$stmt->execute();
18try {
19    var_dump($db->query('SELECT @foo')->fetchAll());
20} catch (PDOException $e) {
21    echo $e->getMessage(), "\n";
22}
23
24?>
25--EXPECT--
26SQLSTATE[HY000]: General error: 2014 Cannot execute queries while there are pending result sets. Consider unsetting the previous PDOStatement or calling PDOStatement::closeCursor()
27