xref: /PHP-8.2/ext/mysqli/tests/bug35517.phpt (revision b5a14e6c)
1--TEST--
2Bug #35517 (mysqli_stmt_fetch returns NULL)
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11    require_once("connect.inc");
12
13    $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
14
15    $mysql->query("CREATE TABLE temp (id INT UNSIGNED NOT NULL)");
16    $mysql->query("INSERT INTO temp (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)");
17    $stmt = $mysql->prepare("SELECT id FROM temp");
18    $stmt->execute();
19    $stmt->bind_result($id);
20    while ($stmt->fetch()) {
21        if (PHP_INT_SIZE == 8) {
22            if ((gettype($id) !== 'int') && (gettype($id) != 'integer'))
23                printf("[001] Expecting integer on 64bit got %s/%s\n", gettype($id), var_export($id, true));
24        } else {
25            if (gettype($id) !== 'string') {
26                printf("[002] Expecting string on 32bit got %s/%s\n", gettype($id), var_export($id, true));
27            }
28        }
29        print $id;
30        print "\n";
31    }
32    $stmt->close();
33
34    $mysql->query("DROP TABLE temp");
35    $mysql->close();
36    print "done!";
37?>
38--CLEAN--
39<?php
40require_once("connect.inc");
41if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
42   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
43
44if (!mysqli_query($link, "DROP TABLE IF EXISTS temp"))
45    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
46
47mysqli_close($link);
48?>
49--EXPECT--
503000000897
513800001532
523900002281
533100059612
54done!
55