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