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