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