036.phpt 1.8 KB

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