xref: /PHP-8.2/ext/mysqli/tests/011.phpt (revision b5a14e6c)
1--TEST--
2mysqli fetch mixed values
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(50)) ENGINE=" . $engine);
26    if (!$rc)
27        printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
28
29    $rc = mysqli_query($link,"INSERT INTO test_bind_result VALUES(19,2999,3999,4999999,
30                                                              2345.6,5678.89563,
31                                                              'foobar','mysql rulez')");
32    if (!$rc)
33        printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
34
35    $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
36    mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8);
37    mysqli_stmt_execute($stmt);
38    mysqli_stmt_fetch($stmt);
39
40    $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
41
42    var_dump($test);
43
44    mysqli_stmt_close($stmt);
45    mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
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_bind_result"))
56    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
57
58mysqli_close($link);
59?>
60--EXPECT--
61array(8) {
62  [0]=>
63  int(19)
64  [1]=>
65  int(2999)
66  [2]=>
67  int(3999)
68  [3]=>
69  int(4999999)
70  [4]=>
71  float(2345.6)
72  [5]=>
73  float(5678.89563)
74  [6]=>
75  string(6) "foobar"
76  [7]=>
77  string(11) "mysql rulez"
78}
79done!
80