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