xref: /PHP-5.5/ext/mysqli/tests/008.phpt (revision 389965f1)
1--TEST--
2mysqli fetch tinyint values
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10	require_once("connect.inc");
11
12	/*** test mysqli_connect 127.0.0.1 ***/
13	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
14
15	if (!mysqli_query($link, "SET sql_mode=''"))
16		printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
17
18	if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
19		printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
20
21	$rc = mysqli_query($link, "CREATE TABLE test_bind_fetch(c1 tinyint,
22													c2 tinyint unsigned,
23													c3 tinyint not NULL,
24													c4 tinyint,
25													c5 tinyint,
26													c6 tinyint unsigned,
27													c7 tinyint) ENGINE=" . $engine);
28	if (!$rc)
29		printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
30
31	if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,300,0,-100,-127,+30,0)"))
32		printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
33
34	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
35	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
36	mysqli_stmt_execute($stmt);
37	mysqli_stmt_fetch($stmt);
38
39	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
40
41	var_dump($test);
42
43	mysqli_stmt_close($stmt);
44	mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
45	mysqli_close($link);
46	print "done!";
47?>
48--CLEAN--
49<?php
50require_once("connect.inc");
51if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
52   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
53
54if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
55	printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
56
57mysqli_close($link);
58?>
59--EXPECT--
60array(7) {
61  [0]=>
62  int(-23)
63  [1]=>
64  int(255)
65  [2]=>
66  int(0)
67  [3]=>
68  int(-100)
69  [4]=>
70  int(-127)
71  [5]=>
72  int(30)
73  [6]=>
74  int(0)
75}
76done!