036.phpt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. --TEST--
  2. function test: mysqli_insert_id()
  3. --SKIPIF--
  4. <?php
  5. if (PHP_INT_SIZE == 8) {
  6. echo 'skip test valid only for 32bit systems';
  7. exit;
  8. }
  9. require_once('skipif.inc');
  10. require_once('skipifconnectfailure.inc');
  11. ?>
  12. --FILE--
  13. <?php
  14. require_once("connect.inc");
  15. /*** test mysqli_connect 127.0.0.1 ***/
  16. $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
  17. mysqli_select_db($link, $db);
  18. mysqli_query($link, "DROP TABLE IF EXISTS t036");
  19. mysqli_query($link, "CREATE TABLE t036 (a bigint not null auto_increment primary key, b varchar(10)) ENGINE = " . $engine);
  20. mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo1')");
  21. $test[] = mysqli_insert_id($link);
  22. /* we have to insert more values, cause lexer sets auto_increment to max_int
  23. see mysql bug #54. So we don't check for the value, only for type (which must
  24. be type string)
  25. */
  26. mysqli_query($link, "ALTER TABLE t036 AUTO_INCREMENT=9999999999999998");
  27. mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo2')");
  28. mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo3')");
  29. mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo4')");
  30. $x = mysqli_insert_id($link);
  31. $test[] = is_string($x);
  32. var_dump($test);
  33. mysqli_query($link, "DROP TABLE IF EXISTS t036");
  34. mysqli_close($link);
  35. print "done!";
  36. ?>
  37. --CLEAN--
  38. <?php
  39. require_once("connect.inc");
  40. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  41. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  42. if (!mysqli_query($link, "DROP TABLE IF EXISTS t036"))
  43. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  44. mysqli_close($link);
  45. ?>
  46. --EXPECT--
  47. array(2) {
  48. [0]=>
  49. int(1)
  50. [1]=>
  51. bool(true)
  52. }
  53. done!