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