1--TEST--
2mysqli_stmt_param_count()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10    require_once("connect.inc");
11
12    require('table.inc');
13
14    if (!$stmt = mysqli_stmt_init($link))
15        printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
16
17    try {
18        mysqli_stmt_param_count($stmt);
19    } catch (Error $exception) {
20        echo $exception->getMessage() . "\n";
21    }
22
23    function func_test_mysqli_stmt_param_count($stmt, $query, $expected, $offset) {
24
25        if (!mysqli_stmt_prepare($stmt, $query)) {
26            printf("[%03d] [%d] %s\n", $offset, mysqli_stmt_errno($stmt), mysqli_error($stmt));
27            return false;
28        }
29
30        if ($expected !== ($tmp = mysqli_stmt_param_count($stmt)))
31            printf("[%03d] Expecting %s/%d, got %s/%d\n", $offset + 3,
32                gettype($expected), $expected,
33                gettype($tmp), $tmp);
34        return true;
35    }
36
37    func_test_mysqli_stmt_param_count($stmt, "SELECT 1 AS a", 0, 10);
38    func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id) VALUES (?)", 1, 20);
39    func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id, label) VALUES (?, ?)", 2, 30);
40    func_test_mysqli_stmt_param_count($stmt, "INSERT INTO test(id, label) VALUES (?, '?')", 1, 40);
41
42    mysqli_stmt_close($stmt);
43
44    try {
45        mysqli_stmt_param_count($stmt);
46    } catch (Error $exception) {
47        echo $exception->getMessage() . "\n";
48    }
49
50    mysqli_close($link);
51
52    print "done!";
53?>
54--CLEAN--
55<?php
56    require_once("clean_table.inc");
57?>
58--EXPECT--
59mysqli_stmt object is not fully initialized
60mysqli_stmt object is already closed
61done!
62