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