mysqli_field_tell.phpt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. --TEST--
  2. mysqli_field_tell()
  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_field_tell()))
  15. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  16. if (!is_null($tmp = @mysqli_field_tell($link)))
  17. printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  18. require('table.inc');
  19. if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1", MYSQLI_USE_RESULT)) {
  20. printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  21. }
  22. var_dump(mysqli_field_tell($res));
  23. var_dump(mysqli_field_seek(1));
  24. var_dump(mysqli_field_tell($res));
  25. var_dump(mysqli_fetch_field($res));
  26. var_dump(mysqli_fetch_field($res));
  27. var_dump(mysqli_field_tell($res));
  28. if (!is_null($tmp = @mysqli_field_tell($res, 'too many arguments')))
  29. printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  30. var_dump(mysqli_field_seek($res, 2));
  31. var_dump(mysqli_field_tell($res));
  32. var_dump(mysqli_field_seek($res, -1));
  33. var_dump(mysqli_field_tell($res));
  34. var_dump(mysqli_field_seek($res, 0));
  35. var_dump(mysqli_field_tell($res));
  36. mysqli_free_result($res);
  37. var_dump(mysqli_field_tell($res));
  38. mysqli_close($link);
  39. print "done!";
  40. ?>
  41. --CLEAN--
  42. <?php
  43. require_once("clean_table.inc");
  44. ?>
  45. --EXPECTF--
  46. int(0)
  47. Warning: mysqli_field_seek() expects exactly 2 parameters, 1 given in %s on line %d
  48. NULL
  49. int(0)
  50. object(stdClass)#%d (13) {
  51. [%u|b%"name"]=>
  52. %unicode|string%(2) "id"
  53. [%u|b%"orgname"]=>
  54. %unicode|string%(2) "id"
  55. [%u|b%"table"]=>
  56. %unicode|string%(4) "test"
  57. [%u|b%"orgtable"]=>
  58. %unicode|string%(4) "test"
  59. [%u|b%"def"]=>
  60. %unicode|string%(0) ""
  61. [%u|b%"db"]=>
  62. %unicode|string%(%d) "%s"
  63. [%u|b%"catalog"]=>
  64. %unicode|string%(%d) "%s"
  65. [%u|b%"max_length"]=>
  66. int(0)
  67. [%u|b%"length"]=>
  68. int(11)
  69. [%u|b%"charsetnr"]=>
  70. int(63)
  71. [%u|b%"flags"]=>
  72. int(49155)
  73. [%u|b%"type"]=>
  74. int(3)
  75. [%u|b%"decimals"]=>
  76. int(0)
  77. }
  78. bool(false)
  79. int(1)
  80. Warning: mysqli_field_seek(): Invalid field offset in %s on line %d
  81. bool(false)
  82. int(1)
  83. Warning: mysqli_field_seek(): Invalid field offset in %s on line %d
  84. bool(false)
  85. int(1)
  86. bool(true)
  87. int(0)
  88. Warning: mysqli_field_tell(): Couldn't fetch mysqli_result in %s on line %d
  89. NULL
  90. done!