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