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