mysqli_fetch_field_direct.phpt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. --TEST--
  2. mysqli_fetch_field_direct()
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifemb.inc');
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once("connect.inc");
  12. $tmp = NULL;
  13. $link = NULL;
  14. if (!is_null($tmp = @mysqli_fetch_field_direct()))
  15. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  16. if (!is_null($tmp = @mysqli_fetch_field_direct($link)))
  17. printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  18. if (!is_null($tmp = @mysqli_fetch_field_direct($link, $link)))
  19. printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  20. require('table.inc');
  21. if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) {
  22. printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  23. }
  24. var_dump(mysqli_fetch_field_direct($res, -1));
  25. var_dump(mysqli_fetch_field_direct($res, 0));
  26. var_dump(mysqli_fetch_field_direct($res, 2));
  27. mysqli_free_result($res);
  28. if (false !== ($tmp = mysqli_fetch_field_direct($res, 0)))
  29. printf("[005] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
  30. mysqli_close($link);
  31. print "done!";
  32. ?>
  33. --CLEAN--
  34. <?php
  35. require_once("clean_table.inc");
  36. ?>
  37. --EXPECTF--
  38. Warning: mysqli_fetch_field_direct(): Field offset is invalid for resultset in %s on line %d
  39. bool(false)
  40. object(stdClass)#%d (13) {
  41. ["name"]=>
  42. string(2) "ID"
  43. ["orgname"]=>
  44. string(2) "id"
  45. ["table"]=>
  46. string(4) "TEST"
  47. ["orgtable"]=>
  48. string(4) "test"
  49. ["def"]=>
  50. string(0) ""
  51. ["db"]=>
  52. string(%d) "%s"
  53. ["catalog"]=>
  54. string(%d) "%s"
  55. ["max_length"]=>
  56. int(%d)
  57. ["length"]=>
  58. int(%d)
  59. ["charsetnr"]=>
  60. int(%d)
  61. ["flags"]=>
  62. int(%d)
  63. ["type"]=>
  64. int(%d)
  65. ["decimals"]=>
  66. int(%d)
  67. }
  68. Warning: mysqli_fetch_field_direct(): Field offset is invalid for resultset in %s on line %d
  69. bool(false)
  70. Warning: mysqli_fetch_field_direct(): Couldn't fetch mysqli_result in %s on line %d
  71. done!