046.phpt 1.3 KB

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