xref: /PHP-5.5/ext/mysqli/tests/026.phpt (revision 389965f1)
1--TEST--
2mysqli bind_param/bind_result with send_long_data
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	mysqli_query($link, "SET sql_mode=''");
17
18	mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
19	mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 varchar(10), c2 text)");
20
21	$stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
22	mysqli_stmt_bind_param($stmt, "sb", $c1, $c2);
23
24	$c1 = "Hello World";
25
26	mysqli_stmt_send_long_data($stmt, 1, "This is the first sentence.");
27	mysqli_stmt_send_long_data($stmt, 1, " And this is the second sentence.");
28	mysqli_stmt_send_long_data($stmt, 1, " And finally this is the last sentence.");
29
30	mysqli_stmt_execute($stmt);
31	mysqli_stmt_close($stmt);
32
33	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
34	mysqli_stmt_bind_result($stmt, $d1, $d2);
35	mysqli_stmt_execute($stmt);
36	mysqli_stmt_fetch($stmt);
37
38	$test = array($d1,$d2);
39
40	var_dump($test);
41
42	mysqli_stmt_close($stmt);
43	mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
44	mysqli_close($link);
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  %unicode|string%(10) "Hello Worl"
62  [1]=>
63  %unicode|string%(99) "This is the first sentence. And this is the second sentence. And finally this is the last sentence."
64}
65done!