1--TEST--
2mysqli_stmt_attr_get()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11    require_once("connect.inc");
12
13    require('table.inc');
14
15    $valid_attr = array(
16        "max_length" => MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH,
17        "cursor_type" => MYSQLI_STMT_ATTR_CURSOR_TYPE,
18        "prefetch_rows" => MYSQLI_STMT_ATTR_PREFETCH_ROWS,
19    );
20
21    $stmt = mysqli_stmt_init($link);
22    mysqli_stmt_prepare($stmt, 'SELECT * FROM test');
23
24    try {
25        mysqli_stmt_attr_get($stmt, -100);
26    } catch (\ValueError $e) {
27        echo $e->getMessage() . \PHP_EOL;
28    }
29
30    foreach ($valid_attr as $k => $attr) {
31        /* This can't happen anymore as it only returns int */
32        if (false === ($tmp = mysqli_stmt_attr_get($stmt, $attr))) {
33            printf("[006] Expecting any type, but not boolean/false, got %s/%s for attribute %s/%s\n",
34                gettype($tmp), $tmp, $k, $attr);
35        }
36    }
37
38    $stmt->close();
39
40    foreach ($valid_attr as $k => $attr) {
41        try {
42            mysqli_stmt_attr_get($stmt, $attr);
43        } catch (Throwable $exception) {
44            echo $exception->getMessage() . "\n";
45        }
46    }
47
48    mysqli_close($link);
49    print "done!";
50?>
51--CLEAN--
52<?php
53    require_once("clean_table.inc");
54?>
55--EXPECT--
56mysqli_stmt_attr_get(): Argument #2 ($attribute) must be one of MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, MYSQLI_STMT_ATTR_PREFETCH_ROWS, or STMT_ATTR_CURSOR_TYPE
57mysqli_stmt object is already closed
58mysqli_stmt object is already closed
59mysqli_stmt object is already closed
60done!
61