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