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