xref: /PHP-8.2/ext/mysqli/tests/046.phpt (revision b5a14e6c)
1--TEST--
2mysqli_stmt_affected_rows (delete)
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_affected");
19    mysqli_query($link, "CREATE TABLE test_affected (foo int) ENGINE=" . $engine);
20
21    mysqli_query($link, "INSERT INTO test_affected VALUES (1),(2),(3),(4),(5)");
22
23    $stmt = mysqli_prepare($link, "DELETE FROM test_affected WHERE foo=?");
24    mysqli_stmt_bind_param($stmt, "i", $c1);
25
26    $c1 = 2;
27
28    mysqli_stmt_execute($stmt);
29    $x = mysqli_stmt_affected_rows($stmt);
30
31    mysqli_stmt_close($stmt);
32    var_dump($x==1);
33
34    mysqli_query($link, "DROP TABLE IF EXISTS test_affected");
35    mysqli_close($link);
36    print "done!";
37?>
38--CLEAN--
39<?php
40require_once("connect.inc");
41if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
42   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
43
44if (!mysqli_query($link, "DROP TABLE IF EXISTS test_affected"))
45    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
46
47mysqli_close($link);
48?>
49--EXPECT--
50bool(true)
51done!
52