xref: /PHP-5.5/ext/mysqli/tests/bug35517.phpt (revision eb0e09f5)
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, '5.9.9', '>') == 1) && !is_unicode($id)) {
28				printf("[003] Expecting unicode string\n");
29			}
30		}
31		print $id;
32		print "\n";
33	}
34	$stmt->close();
35
36	$mysql->query("DROP TABLE temp");
37	$mysql->close();
38	print "done!";
39?>
40--CLEAN--
41<?php
42require_once("connect.inc");
43if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
44   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
45
46if (!mysqli_query($link, "DROP TABLE IF EXISTS temp"))
47	printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
48
49mysqli_close($link);
50?>
51--EXPECTF--
523000000897
533800001532
543900002281
553100059612
56done!