1--TEST--
2mysqli_stmt_get_result() - meta data, field_count()
3--SKIPIF--
4<?php
5    require_once('skipif.inc');
6    require_once('skipifconnectfailure.inc');
7
8    if (!function_exists('mysqli_stmt_get_result'))
9        die('skip mysqli_stmt_get_result not available');
10?>
11--FILE--
12<?php
13    require('table.inc');
14
15    if (!$stmt = mysqli_stmt_init($link))
16        printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
17
18    if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id ASC LIMIT 3"))
19        printf("[002] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
20
21    if (!mysqli_stmt_execute($stmt))
22        printf("[003] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
23
24    if (!is_object($res = mysqli_stmt_get_result($stmt)) || 'mysqli_result' != get_class($res)) {
25        printf("[004] Expecting object/mysqli_result got %s/%s, [%d] %s\n",
26            gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
27    }
28
29    if (!is_object($res_meta = mysqli_stmt_result_metadata($stmt)) ||
30        'mysqli_result' != get_class($res_meta)) {
31        printf("[005] Expecting object/mysqli_result got %s/%s, [%d] %s\n",
32            gettype($res), $res, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
33    }
34
35    printf("%s %s\n",
36    $res_meta->field_count,
37    $res->field_count);
38
39    mysqli_stmt_close($stmt);
40    mysqli_close($link);
41    print "done!";
42?>
43--CLEAN--
44<?php
45    require_once("clean_table.inc");
46?>
47--EXPECT--
482 2
49done!
50