1--TEST--
2mysqli_stmt_close()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11    require 'table.inc';
12
13    if (!$stmt = mysqli_stmt_init($link))
14        printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
15
16    // Yes, amazing, eh? AFAIK a workaround of a constructor bug...
17    try {
18        mysqli_stmt_close($stmt);
19    } catch (Error $exception) {
20        echo $exception->getMessage() . "\n";
21    }
22
23    if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test"))
24        printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
25
26    mysqli_stmt_close($stmt);
27
28    try {
29        mysqli_stmt_close($stmt);
30    } catch (Error $exception) {
31        echo $exception->getMessage() . "\n";
32    }
33
34    if (!$stmt = mysqli_stmt_init($link))
35        printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
36
37    if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)"))
38        printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
39
40    $id = $label = null;
41    if (!mysqli_stmt_bind_param($stmt, "is", $id, $label))
42        printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
43
44    $id = 100; $label = 'z';
45    if (!mysqli_stmt_execute($stmt))
46        printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
47
48    $link->query('KILL '.mysqli_thread_id($link));
49
50    mysqli_stmt_close($stmt);
51
52    mysqli_close($link);
53
54    require 'table.inc';
55    if (!$stmt = mysqli_stmt_init($link))
56        printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
57
58    if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test"))
59        printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
60
61    $id = $label = null;
62    if (!mysqli_stmt_bind_result($stmt, $id, $label))
63        printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
64
65    if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt))
66        printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
67
68    $link->query('KILL '.mysqli_thread_id($link));
69
70    mysqli_stmt_close($stmt);
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