xref: /PHP-8.1/ext/mysqli/tests/012.phpt (revision b5a14e6c)
1--TEST--
2mysqli fetch mixed values 2
3--INI--
4precision=12
5--EXTENSIONS--
6mysqli
7--SKIPIF--
8<?php
9require_once('skipifconnectfailure.inc');
10?>
11--FILE--
12<?php
13    require_once("connect.inc");
14
15    /*** test mysqli_connect 127.0.0.1 ***/
16    $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
17
18    if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result"))
19        printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
20
21    $rc = mysqli_query($link, "CREATE TABLE test_bind_result(c1 tinyint, c2 smallint,
22                                                        c3 int, c4 bigint,
23                                                        c5 float, c6 double,
24                                                        c7 varbinary(10),
25                                                        c8 varchar(10)) ENGINE=" . $engine);
26    if (!$rc)
27        printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
28
29    if (!mysqli_query($link, "INSERT INTO test_bind_result VALUES(120,2999,3999,54,
30                                                            2.6,58.89,
31                                                            '206','6.7')"))
32        printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
33
34    $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
35    mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
36    mysqli_stmt_execute($stmt);
37    mysqli_stmt_fetch($stmt);
38
39    $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
40
41    var_dump($test);
42
43    mysqli_stmt_close($stmt);
44    mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
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_result"))
55    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
56
57mysqli_close($link);
58?>
59--EXPECT--
60array(8) {
61  [0]=>
62  int(120)
63  [1]=>
64  int(2999)
65  [2]=>
66  int(3999)
67  [3]=>
68  int(54)
69  [4]=>
70  float(2.6)
71  [5]=>
72  float(58.89)
73  [6]=>
74  string(3) "206"
75  [7]=>
76  string(3) "6.7"
77}
78done!
79