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