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