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