xref: /php-src/ext/mysqli/tests/058.phpt (revision a21edc52)
1--TEST--
2multiple binds
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 mbind");
19    mysqli_query($link,"CREATE TABLE mbind (a int, b varchar(10))");
20
21    $stmt = mysqli_prepare($link, "INSERT INTO mbind VALUES (?,?)");
22
23    mysqli_stmt_bind_param($stmt, "is", $a, $b);
24
25    $a = 1;
26    $b = "foo";
27
28    mysqli_stmt_execute($stmt);
29
30    mysqli_stmt_bind_param($stmt, "is", $c, $d);
31
32    $c = 2;
33    $d = "bar";
34
35    mysqli_stmt_execute($stmt);
36    mysqli_stmt_close($stmt);
37
38    $stmt = mysqli_prepare($link, "SELECT * FROM mbind");
39    mysqli_stmt_execute($stmt);
40
41    mysqli_stmt_bind_result($stmt, $e, $f);
42    mysqli_stmt_fetch($stmt);
43
44    mysqli_stmt_bind_result($stmt, $g, $h);
45    mysqli_stmt_fetch($stmt);
46
47    var_dump((array($e,$f,$g,$h)));
48
49    mysqli_close($link);
50    print "done!";
51?>
52--CLEAN--
53<?php
54require_once 'connect.inc';
55if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
56   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
57
58if (!mysqli_query($link, "DROP TABLE IF EXISTS mbind"))
59    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
60
61mysqli_close($link);
62?>
63--EXPECT--
64array(4) {
65  [0]=>
66  int(1)
67  [1]=>
68  string(3) "foo"
69  [2]=>
70  int(2)
71  [3]=>
72  string(3) "bar"
73}
74done!
75