xref: /php-src/ext/mysqli/tests/043.phpt (revision a21edc52)
1--TEST--
2mysqli_stmt_bind_param (UPDATE)
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 test_update");
19    mysqli_query($link,"CREATE TABLE test_update(a varchar(10),
20        b int) ENGINE=" . $engine);
21
22    mysqli_query($link, "INSERT INTO test_update VALUES ('foo', 2)");
23
24    $stmt = mysqli_prepare($link, "UPDATE test_update SET a=?,b=? WHERE b=?");
25    mysqli_stmt_bind_param($stmt, "sii", $c1, $c2, $c3);
26
27    $c1 = "Rasmus";
28    $c2 = 1;
29    $c3 = 2;
30
31    mysqli_stmt_execute($stmt);
32    mysqli_stmt_close($stmt);
33
34    $result = mysqli_query($link, "SELECT concat(a, ' is No. ', b) FROM test_update");
35    $test = mysqli_fetch_row($result);
36    mysqli_free_result($result);
37
38    var_dump($test);
39
40    mysqli_query($link, "DROP TABLE IF EXISTS test_update");
41    mysqli_close($link);
42    print "done!";
43?>
44--CLEAN--
45<?php
46require_once 'connect.inc';
47if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
48   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
49
50if (!mysqli_query($link, "DROP TABLE IF EXISTS test_update"))
51    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
52
53mysqli_close($link);
54?>
55--EXPECT--
56array(1) {
57  [0]=>
58  string(15) "Rasmus is No. 1"
59}
60done!
61