1--TEST--
2mysqli_free_result()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11    require_once("connect.inc");
12
13    require('table.inc');
14    if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) {
15        printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
16    }
17
18    print "a\n";
19    var_dump(mysqli_free_result($res));
20
21    print "b\n";
22    try {
23        mysqli_free_result($res);
24    } catch (Error $exception) {
25        echo $exception->getMessage() . "\n";
26    }
27
28    if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) {
29        printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
30    }
31
32    print "c\n";
33    var_dump(mysqli_store_result($link));
34    var_dump(mysqli_error($link));
35    print "[005]\n";
36
37    mysqli_free_result($res);
38
39    if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) {
40        printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
41    }
42    print "d\n";
43    var_dump(mysqli_use_result($link));
44    var_dump(mysqli_error($link));
45    print "[007]\n";
46    var_dump(mysqli_free_result($res));
47
48    mysqli_close($link);
49    print "done!";
50?>
51--CLEAN--
52<?php
53    require_once("clean_table.inc");
54?>
55--EXPECT--
56a
57NULL
58b
59mysqli_result object is already closed
60c
61bool(false)
62string(0) ""
63[005]
64d
65bool(false)
66string(0) ""
67[007]
68NULL
69done!
70