xref: /PHP-8.3/ext/mysqli/tests/023.phpt (revision a21edc52)
1--TEST--
2mysqli bind_param/bind_prepare fetch long 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 int unsigned,
21        c2 int unsigned,
22        c3 int,
23        c4 int,
24        c5 int,
25        c6 int unsigned,
26        c7 int)");
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    $c1 = -23;
31    $c2 = 35999;
32    $c3 = NULL;
33    $c4 = -500;
34    $c5 = -9999999;
35    $c6 = -0;
36    $c7 = 0;
37
38    mysqli_stmt_execute($stmt);
39    mysqli_stmt_close($stmt);
40
41    $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
42    mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
43    mysqli_stmt_execute($stmt);
44    mysqli_stmt_fetch($stmt);
45
46    $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
47
48    var_dump($test);
49
50    mysqli_stmt_close($stmt);
51    mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
52    mysqli_close($link);
53
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(-9999999)
79  [5]=>
80  int(0)
81  [6]=>
82  int(0)
83}
84done!
85