mysql_field_seek.phpt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. --TEST--
  2. mysql_field_seek()
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifconnectfailure.inc');
  7. ?>
  8. --FILE--
  9. <?php
  10. include "connect.inc";
  11. $tmp = NULL;
  12. $link = NULL;
  13. if (!is_null($tmp = @mysql_field_seek()))
  14. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  15. if (!is_null($tmp = @mysql_field_seek($link)))
  16. printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  17. require('table.inc');
  18. if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 1", $link)) {
  19. printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
  20. }
  21. var_dump(mysql_field_seek($res, -1));
  22. var_dump(mysql_fetch_field($res));
  23. var_dump(mysql_field_seek($res, 0));
  24. var_dump(mysql_fetch_field($res));
  25. var_dump(mysql_field_seek($res, 1));
  26. var_dump(mysql_fetch_field($res));
  27. var_dump(mysql_field_seek($res, 2));
  28. var_dump(mysql_fetch_field($res));
  29. mysql_free_result($res);
  30. var_dump(mysql_field_seek($res, 0));
  31. mysql_close($link);
  32. print "done!";
  33. ?>
  34. --CLEAN--
  35. <?php
  36. require_once("clean_table.inc");
  37. ?>
  38. --EXPECTF--
  39. Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
  40. Warning: mysql_field_seek(): Field -1 is invalid for MySQL result index %d in %s on line %d
  41. bool(false)
  42. object(stdClass)#%d (13) {
  43. [%u|b%"name"]=>
  44. %unicode|string%(2) "id"
  45. [%u|b%"table"]=>
  46. %unicode|string%(4) "test"
  47. [%u|b%"def"]=>
  48. %unicode|string%(0) ""
  49. [%u|b%"max_length"]=>
  50. int(1)
  51. [%u|b%"not_null"]=>
  52. int(1)
  53. [%u|b%"primary_key"]=>
  54. int(1)
  55. [%u|b%"multiple_key"]=>
  56. int(0)
  57. [%u|b%"unique_key"]=>
  58. int(0)
  59. [%u|b%"numeric"]=>
  60. int(1)
  61. [%u|b%"blob"]=>
  62. int(0)
  63. [%u|b%"type"]=>
  64. %unicode|string%(3) "int"
  65. [%u|b%"unsigned"]=>
  66. int(0)
  67. [%u|b%"zerofill"]=>
  68. int(0)
  69. }
  70. bool(true)
  71. object(stdClass)#%d (13) {
  72. [%u|b%"name"]=>
  73. %unicode|string%(2) "id"
  74. [%u|b%"table"]=>
  75. %unicode|string%(4) "test"
  76. [%u|b%"def"]=>
  77. %unicode|string%(0) ""
  78. [%u|b%"max_length"]=>
  79. int(1)
  80. [%u|b%"not_null"]=>
  81. int(1)
  82. [%u|b%"primary_key"]=>
  83. int(1)
  84. [%u|b%"multiple_key"]=>
  85. int(0)
  86. [%u|b%"unique_key"]=>
  87. int(0)
  88. [%u|b%"numeric"]=>
  89. int(1)
  90. [%u|b%"blob"]=>
  91. int(0)
  92. [%u|b%"type"]=>
  93. %unicode|string%(3) "int"
  94. [%u|b%"unsigned"]=>
  95. int(0)
  96. [%u|b%"zerofill"]=>
  97. int(0)
  98. }
  99. bool(true)
  100. object(stdClass)#%d (13) {
  101. [%u|b%"name"]=>
  102. %unicode|string%(5) "label"
  103. [%u|b%"table"]=>
  104. %unicode|string%(4) "test"
  105. [%u|b%"def"]=>
  106. %unicode|string%(0) ""
  107. [%u|b%"max_length"]=>
  108. int(1)
  109. [%u|b%"not_null"]=>
  110. int(0)
  111. [%u|b%"primary_key"]=>
  112. int(0)
  113. [%u|b%"multiple_key"]=>
  114. int(0)
  115. [%u|b%"unique_key"]=>
  116. int(0)
  117. [%u|b%"numeric"]=>
  118. int(0)
  119. [%u|b%"blob"]=>
  120. int(0)
  121. [%u|b%"type"]=>
  122. %unicode|string%(6) "string"
  123. [%u|b%"unsigned"]=>
  124. int(0)
  125. [%u|b%"zerofill"]=>
  126. int(0)
  127. }
  128. Warning: mysql_field_seek(): Field %d is invalid for MySQL result index %d in %s on line %d
  129. bool(false)
  130. bool(false)
  131. Warning: mysql_field_seek(): %d is not a valid MySQL result resource in %s on line %d
  132. bool(false)
  133. done!