xref: /PHP-8.2/ext/mysqli/tests/024.phpt (revision b5a14e6c)
1--TEST--
2mysqli bind_param/bind_result short values
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    $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
15
16    mysqli_select_db($link, $db);
17    mysqli_query($link, "SET sql_mode=''");
18
19    mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
20    mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,
21        c2 smallint unsigned,
22        c3 smallint,
23        c4 smallint,
24        c5 smallint,
25        c6 smallint unsigned,
26        c7 smallint)");
27
28    $stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)");
29    mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
30
31    $c1 = -23;
32    $c2 = 35999;
33    $c3 = NULL;
34    $c4 = -500;
35    $c5 = -9999999;
36    $c6 = -0;
37    $c7 = 0;
38
39    mysqli_stmt_execute($stmt);
40    mysqli_stmt_close($stmt);
41
42    $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
43    mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
44    mysqli_stmt_execute($stmt);
45    mysqli_stmt_fetch($stmt);
46
47    $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
48
49    var_dump($test);
50
51    mysqli_stmt_close($stmt);
52    mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
53    mysqli_close($link);
54    print "done!";
55?>
56--CLEAN--
57<?php
58require_once("connect.inc");
59if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
60   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
61
62if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
63    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
64
65mysqli_close($link);
66?>
67--EXPECT--
68array(7) {
69  [0]=>
70  int(0)
71  [1]=>
72  int(35999)
73  [2]=>
74  NULL
75  [3]=>
76  int(-500)
77  [4]=>
78  int(-32768)
79  [5]=>
80  int(0)
81  [6]=>
82  int(0)
83}
84done!
85