xref: /PHP-7.2/ext/mysqli/tests/025.phpt (revision f1d7e3ca)
1--TEST--
2mysqli bind_param/bind_result tinyint values
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 tinyint,
20		c2 tinyint unsigned,
21		c3 tinyint not NULL,
22		c4 tinyint,
23		c5 tinyint,
24		c6 tinyint unsigned,
25		c7 tinyint)");
26
27	$stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES(?,?,?,?,?,?,?)");
28	mysqli_stmt_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7);
29
30	$c1 = -23;
31	$c2 = 300;
32	$c3 = 0;
33	$c4 = -100;
34	$c5 = -127;
35	$c6 = 30;
36	$c7 = 0;
37
38	mysqli_stmt_execute($stmt);
39	mysqli_stmt_close($stmt);
40
41	mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,300,0,-100,-127,+30,0)");
42
43	$c1 = $c2 = $c3 = $c4 = $c5 = $c6 = $c7 = NULL;
44
45	$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
46	mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
47	mysqli_stmt_execute($stmt);
48	mysqli_stmt_fetch($stmt);
49
50	$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
51
52	var_dump($test);
53
54	mysqli_stmt_close($stmt);
55	mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
56	mysqli_close($link);
57
58	print "done!";
59?>
60--CLEAN--
61<?php
62require_once("connect.inc");
63if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
64   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
65
66if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch"))
67	printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
68
69mysqli_close($link);
70?>
71--EXPECT--
72array(7) {
73  [0]=>
74  int(-23)
75  [1]=>
76  int(255)
77  [2]=>
78  int(0)
79  [3]=>
80  int(-100)
81  [4]=>
82  int(-127)
83  [5]=>
84  int(30)
85  [6]=>
86  int(0)
87}
88done!
89