xref: /PHP-7.0/ext/mysqli/tests/048.phpt (revision eb0e09f5)
1--TEST--
2mysqli bind_result (OO-Style)
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	$mysql = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
14
15	$mysql->select_db($db);
16	$mysql->query("DROP TABLE IF EXISTS test_fetch_null");
17
18	$mysql->query("CREATE TABLE test_fetch_null(col1 tinyint, col2 smallint,
19		col3 int, col4 bigint,
20		col5 float, col6 double,
21		col7 date, col8 time,
22		col9 varbinary(10),
23		col10 varchar(50),
24		col11 char(20)) ENGINE=" . $engine);
25
26	$mysql->query("INSERT INTO test_fetch_null(col1,col10, col11) VALUES(1,'foo1', 1000),(2,'foo2', 88),(3,'foo3', 389789)");
27
28	$stmt = $mysql->prepare("SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from test_fetch_null");
29	$stmt->bind_result($c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
30	$stmt->execute();
31
32	$stmt->fetch();
33
34	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11);
35
36	var_dump($test);
37
38	$stmt->close();
39	$mysql->query("DROP TABLE IF EXISTS test_fetch_null");
40	$mysql->close();
41	print "done!";
42?>
43--CLEAN--
44<?php
45require_once("connect.inc");
46if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
47   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
48
49if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
50	printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
51
52mysqli_close($link);
53?>
54--EXPECTF--
55array(11) {
56  [0]=>
57  int(1)
58  [1]=>
59  NULL
60  [2]=>
61  NULL
62  [3]=>
63  NULL
64  [4]=>
65  NULL
66  [5]=>
67  NULL
68  [6]=>
69  NULL
70  [7]=>
71  NULL
72  [8]=>
73  NULL
74  [9]=>
75  %unicode|string%(4) "foo1"
76  [10]=>
77  %unicode|string%(4) "1000"
78}
79done!