xref: /PHP-7.4/ext/mysqli/tests/022.phpt (revision e3e67b72)
1--TEST--
2mysqli bind_param/bind_result char/text long
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
17    mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
18    mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
19
20
21    $stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
22    mysqli_stmt_bind_param($stmt, "ss", $a1, $a2);
23
24    $a1 = "1234567890";
25    $a2 = str_repeat("A1", 32000);
26
27    mysqli_stmt_execute($stmt);
28    mysqli_stmt_close($stmt);
29
30    $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
31    mysqli_stmt_bind_result($stmt, $c1, $c2);
32    mysqli_stmt_execute($stmt);
33    mysqli_stmt_fetch($stmt);
34
35    $test[] = $c1;
36    $test[] = ($a2 == $c2) ? "32K String ok" : "32K String failed";
37
38    var_dump($test);
39
40    mysqli_stmt_close($stmt);
41    mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
42    mysqli_close($link);
43
44    print "done!";
45?>
46--CLEAN--
47<?php
48require_once("connect.inc");
49if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
50   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
51
52if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
53    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
54
55mysqli_close($link);
56?>
57--EXPECTF--
58array(2) {
59  [0]=>
60  string(10) "1234567890"
61  [1]=>
62  %s(13) "32K String ok"
63}
64done!
65