mysqli_fetch_field_direct.phpt 2.0 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 (NULL !== ($tmp = mysqli_fetch_field_direct($res, 0)))
  29. printf("Expecting NULL, 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. [%u|b%"name"]=>
  42. %unicode|string%(2) "ID"
  43. [%u|b%"orgname"]=>
  44. %unicode|string%(2) "id"
  45. [%u|b%"table"]=>
  46. %unicode|string%(4) "TEST"
  47. [%u|b%"orgtable"]=>
  48. %unicode|string%(4) "test"
  49. [%u|b%"def"]=>
  50. %unicode|string%(0) ""
  51. [%u|b%"db"]=>
  52. %unicode|string%(%d) "%s"
  53. [%u|b%"catalog"]=>
  54. %unicode|string%(%d) "%s"
  55. [%u|b%"max_length"]=>
  56. int(%d)
  57. [%u|b%"length"]=>
  58. int(%d)
  59. [%u|b%"charsetnr"]=>
  60. int(%d)
  61. [%u|b%"flags"]=>
  62. int(%d)
  63. [%u|b%"type"]=>
  64. int(%d)
  65. [%u|b%"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!