046.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. mysqli_stmt_affected_rows (delete)
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once("connect.inc");
  12. /*** test mysqli_connect 127.0.0.1 ***/
  13. $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
  14. mysqli_select_db($link, $db);
  15. mysqli_query($link, "DROP TABLE IF EXISTS test_affected");
  16. mysqli_query($link, "CREATE TABLE test_affected (foo int) ENGINE=" . $engine);
  17. mysqli_query($link, "INSERT INTO test_affected VALUES (1),(2),(3),(4),(5)");
  18. $stmt = mysqli_prepare($link, "DELETE FROM test_affected WHERE foo=?");
  19. mysqli_stmt_bind_param($stmt, "i", $c1);
  20. $c1 = 2;
  21. mysqli_stmt_execute($stmt);
  22. $x = mysqli_stmt_affected_rows($stmt);
  23. mysqli_stmt_close($stmt);
  24. var_dump($x==1);
  25. mysqli_query($link, "DROP TABLE IF EXISTS test_affected");
  26. mysqli_close($link);
  27. print "done!";
  28. ?>
  29. --CLEAN--
  30. <?php
  31. require_once("connect.inc");
  32. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  33. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  34. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_affected"))
  35. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  36. mysqli_close($link);
  37. ?>
  38. --EXPECT--
  39. bool(true)
  40. done!