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