1--TEST--
2mysqli_stmt_free_result()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10    /*
11    NOTE: no datatype tests here! This is done by
12    mysqli_stmt_bind_result.phpt already. Restrict
13    this test case to the basics.
14    */
15    require_once("connect.inc");
16
17    require('table.inc');
18
19    if (!$stmt = mysqli_stmt_init($link))
20        printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
21
22    // stmt object status test
23    try {
24        mysqli_stmt_free_result($stmt);
25    } catch (Error $exception) {
26        echo $exception->getMessage() . "\n";
27    }
28
29    if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id"))
30        printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
31
32    if (NULL !== ($tmp = mysqli_stmt_free_result($stmt)))
33        printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
34
35    if (!mysqli_stmt_execute($stmt))
36        printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
37
38    if (NULL !== ($tmp = mysqli_stmt_free_result($stmt)))
39        printf("[008] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
40
41    if (false !== ($tmp = mysqli_stmt_store_result($stmt)))
42        printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
43
44    mysqli_stmt_close($stmt);
45
46    if (!$stmt = mysqli_stmt_init($link))
47        printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
48
49    if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id"))
50        printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
51
52    if (!mysqli_stmt_execute($stmt))
53        printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
54
55    if (true !== ($tmp = mysqli_stmt_store_result($stmt)))
56        printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
57
58    if (NULL !== ($tmp = mysqli_stmt_free_result($stmt)))
59        printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
60
61    mysqli_stmt_close($stmt);
62
63    try {
64        mysqli_stmt_free_result($stmt);
65    } catch (Error $exception) {
66        echo $exception->getMessage() . "\n";
67    }
68
69    mysqli_close($link);
70
71    print "done!";
72?>
73--CLEAN--
74<?php
75    require_once("clean_table.inc");
76?>
77--EXPECT--
78mysqli_stmt object is not fully initialized
79mysqli_stmt object is already closed
80done!
81