mysqli_info.phpt 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. --TEST--
  2. mysqli_info()
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --INI--
  10. mysqli.allow_local_infile=1
  11. --FILE--
  12. <?php
  13. require_once("connect.inc");
  14. require "table.inc";
  15. if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')"))
  16. printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  17. // NOTE: empty string, no multiple insert syntax
  18. if (!is_null($tmp = mysqli_info($link)) || ('' != $tmp))
  19. printf("[004] Expecting null, got %s/%s\n", gettype($tmp), $tmp);
  20. if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (101, 'a'), (102, 'b')"))
  21. printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  22. if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
  23. printf("[006] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
  24. if (!$res = mysqli_query($link, 'INSERT INTO test(id, label) SELECT id + 200, label FROM test'))
  25. printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  26. if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
  27. printf("[008] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
  28. if (!$res = mysqli_query($link, 'ALTER TABLE test MODIFY label CHAR(2)'))
  29. printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  30. if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
  31. printf("[010] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
  32. if (!$res = mysqli_query($link, "UPDATE test SET label = 'b' WHERE id >= 100"))
  33. printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  34. if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
  35. printf("[012] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
  36. if (!$res = mysqli_query($link, "SELECT 1"))
  37. printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  38. if (!is_null($tmp = mysqli_info($link)) || ('' != $tmp))
  39. printf("[014] Expecting null, got %s/%s\n", gettype($tmp), $tmp);
  40. mysqli_free_result($res);
  41. // NOTE: no LOAD DATA INFILE test
  42. if ($dir = sys_get_temp_dir()) {
  43. do {
  44. $file = $dir . '/' . 'mysqli_info_phpt.cvs';
  45. if (!$fp = fopen($file, 'w'))
  46. /* ignore this error */
  47. break;
  48. if (!fwrite($fp, "100;'a';\n") ||
  49. !fwrite($fp, "101;'b';\n") ||
  50. !fwrite($fp, "102;'c';\n")) {
  51. @unlink($file);
  52. break;
  53. }
  54. fclose($fp);
  55. if (!mysqli_query($link, "DELETE FROM test")) {
  56. printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  57. break;
  58. }
  59. if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY '\n'", $file))) {
  60. /* ok, because we might not be allowed to do this */
  61. @unlink($file);
  62. break;
  63. }
  64. if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
  65. printf("[016] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
  66. unlink($file);
  67. } while (false);
  68. }
  69. print "done!";
  70. ?>
  71. --CLEAN--
  72. <?php
  73. require_once("clean_table.inc");
  74. ?>
  75. --EXPECT--
  76. done!