xref: /PHP-8.1/ext/mysqli/tests/bug80837.phpt (revision ac18dd0d)
1--TEST--
2Bug #80837 Calling stmt_store_result after fetch doesn't throw an error
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8if (!defined('MYSQLI_STORE_RESULT_COPY_DATA')) die('skip requires mysqlnd');
9?>
10--FILE--
11<?php
12require_once "connect.inc";
13
14mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
15$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
16
17$mysqli->query('DROP TABLE IF EXISTS test');
18$mysqli->query('CREATE TABLE test (b int)');
19$mysqli->query('INSERT INTO test VALUES (1),(2),(3)');
20
21$statement = $mysqli->prepare("SELECT b FROM test");
22$statement->execute();
23$statement->bind_result($name);
24$statement->fetch();
25try {
26    $statement->store_result();
27} catch (mysqli_sql_exception $e) {
28    echo $e->getMessage();
29}
30
31$mysqli->close();
32
33?>
34--CLEAN--
35<?php
36require_once "clean_table.inc";
37?>
38--EXPECT--
39Commands out of sync; you can't run this command now
40