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