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 'table.inc';
17
18    if (!$stmt = mysqli_stmt_init($link))
19        printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
20
21    // stmt object status test
22    try {
23        mysqli_stmt_free_result($stmt);
24    } catch (Error $exception) {
25        echo $exception->getMessage() . "\n";
26    }
27
28    if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id"))
29        printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
30
31    if (NULL !== ($tmp = mysqli_stmt_free_result($stmt)))
32        printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
33
34    if (!mysqli_stmt_execute($stmt))
35        printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
36
37    if (NULL !== ($tmp = mysqli_stmt_free_result($stmt)))
38        printf("[008] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
39
40    if (false !== ($tmp = mysqli_stmt_store_result($stmt)))
41        printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
42
43    mysqli_stmt_close($stmt);
44
45    if (!$stmt = mysqli_stmt_init($link))
46        printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
47
48    if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id"))
49        printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
50
51    if (!mysqli_stmt_execute($stmt))
52        printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
53
54    if (true !== ($tmp = mysqli_stmt_store_result($stmt)))
55        printf("[013] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
56
57    if (NULL !== ($tmp = mysqli_stmt_free_result($stmt)))
58        printf("[014] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
59
60    mysqli_stmt_close($stmt);
61
62    try {
63        mysqli_stmt_free_result($stmt);
64    } catch (Error $exception) {
65        echo $exception->getMessage() . "\n";
66    }
67
68    mysqli_close($link);
69
70    print "done!";
71?>
72--CLEAN--
73<?php
74    require_once 'clean_table.inc';
75?>
76--EXPECT--
77mysqli_stmt object is not fully initialized
78mysqli_stmt object is already closed
79done!
80