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