047.phpt 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. --TEST--
  2. mysqli_stmt_result_metadata
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once("connect.inc");
  12. /*** test mysqli_connect 127.0.0.1 ***/
  13. $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
  14. mysqli_select_db($link, $db);
  15. mysqli_query($link, "DROP TABLE IF EXISTS test_affected");
  16. mysqli_query($link, "CREATE TABLE test_affected (foo int, bar varchar(10) character set latin1) ENGINE=" . $engine);
  17. mysqli_query($link, "INSERT INTO test_affected VALUES (1, 'Zak'),(2, 'Greant')");
  18. $stmt = mysqli_prepare($link, "SELECT * FROM test_affected");
  19. mysqli_stmt_execute($stmt);
  20. $result = mysqli_stmt_result_metadata($stmt);
  21. echo "\n=== fetch_fields ===\n";
  22. var_dump(mysqli_fetch_fields($result));
  23. echo "\n=== fetch_field_direct ===\n";
  24. var_dump(mysqli_fetch_field_direct($result, 0));
  25. var_dump(mysqli_fetch_field_direct($result, 1));
  26. echo "\n=== fetch_field ===\n";
  27. while ($field = mysqli_fetch_field($result)) {
  28. var_dump($field);
  29. }
  30. print_r(mysqli_fetch_lengths($result));
  31. mysqli_free_result($result);
  32. mysqli_stmt_close($stmt);
  33. mysqli_query($link, "DROP TABLE IF EXISTS test_affected");
  34. mysqli_close($link);
  35. print "done!";
  36. ?>
  37. --CLEAN--
  38. <?php
  39. require_once("connect.inc");
  40. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  41. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  42. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_affected"))
  43. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  44. mysqli_close($link);
  45. ?>
  46. --EXPECTF--
  47. === fetch_fields ===
  48. array(2) {
  49. [0]=>
  50. object(stdClass)#5 (13) {
  51. ["name"]=>
  52. string(3) "foo"
  53. ["orgname"]=>
  54. string(3) "foo"
  55. ["table"]=>
  56. string(13) "test_affected"
  57. ["orgtable"]=>
  58. string(13) "test_affected"
  59. ["def"]=>
  60. string(0) ""
  61. ["db"]=>
  62. string(%d) "%s"
  63. ["catalog"]=>
  64. string(%d) "%s"
  65. ["max_length"]=>
  66. int(0)
  67. ["length"]=>
  68. int(%d)
  69. ["charsetnr"]=>
  70. int(%d)
  71. ["flags"]=>
  72. int(32768)
  73. ["type"]=>
  74. int(3)
  75. ["decimals"]=>
  76. int(0)
  77. }
  78. [1]=>
  79. object(stdClass)#6 (13) {
  80. ["name"]=>
  81. string(3) "bar"
  82. ["orgname"]=>
  83. string(3) "bar"
  84. ["table"]=>
  85. string(13) "test_affected"
  86. ["orgtable"]=>
  87. string(13) "test_affected"
  88. ["def"]=>
  89. string(0) ""
  90. ["db"]=>
  91. string(%d) "%s"
  92. ["catalog"]=>
  93. string(%d) "%s"
  94. ["max_length"]=>
  95. int(0)
  96. ["length"]=>
  97. int(%d)
  98. ["charsetnr"]=>
  99. int(%d)
  100. ["flags"]=>
  101. int(0)
  102. ["type"]=>
  103. int(253)
  104. ["decimals"]=>
  105. int(0)
  106. }
  107. }
  108. === fetch_field_direct ===
  109. object(stdClass)#6 (13) {
  110. ["name"]=>
  111. string(3) "foo"
  112. ["orgname"]=>
  113. string(3) "foo"
  114. ["table"]=>
  115. string(13) "test_affected"
  116. ["orgtable"]=>
  117. string(13) "test_affected"
  118. ["def"]=>
  119. string(0) ""
  120. ["db"]=>
  121. string(%d) "%s"
  122. ["catalog"]=>
  123. string(%d) "%s"
  124. ["max_length"]=>
  125. int(0)
  126. ["length"]=>
  127. int(%d)
  128. ["charsetnr"]=>
  129. int(%d)
  130. ["flags"]=>
  131. int(32768)
  132. ["type"]=>
  133. int(3)
  134. ["decimals"]=>
  135. int(0)
  136. }
  137. object(stdClass)#6 (13) {
  138. ["name"]=>
  139. string(3) "bar"
  140. ["orgname"]=>
  141. string(3) "bar"
  142. ["table"]=>
  143. string(13) "test_affected"
  144. ["orgtable"]=>
  145. string(13) "test_affected"
  146. ["def"]=>
  147. string(0) ""
  148. ["db"]=>
  149. string(%d) "%s"
  150. ["catalog"]=>
  151. string(%d) "%s"
  152. ["max_length"]=>
  153. int(0)
  154. ["length"]=>
  155. int(%d)
  156. ["charsetnr"]=>
  157. int(%d)
  158. ["flags"]=>
  159. int(0)
  160. ["type"]=>
  161. int(253)
  162. ["decimals"]=>
  163. int(0)
  164. }
  165. === fetch_field ===
  166. object(stdClass)#6 (13) {
  167. ["name"]=>
  168. string(3) "foo"
  169. ["orgname"]=>
  170. string(3) "foo"
  171. ["table"]=>
  172. string(13) "test_affected"
  173. ["orgtable"]=>
  174. string(13) "test_affected"
  175. ["def"]=>
  176. string(0) ""
  177. ["db"]=>
  178. string(%d) "%s"
  179. ["catalog"]=>
  180. string(%d) "%s"
  181. ["max_length"]=>
  182. int(0)
  183. ["length"]=>
  184. int(%d)
  185. ["charsetnr"]=>
  186. int(%d)
  187. ["flags"]=>
  188. int(32768)
  189. ["type"]=>
  190. int(3)
  191. ["decimals"]=>
  192. int(0)
  193. }
  194. object(stdClass)#5 (13) {
  195. ["name"]=>
  196. string(3) "bar"
  197. ["orgname"]=>
  198. string(3) "bar"
  199. ["table"]=>
  200. string(13) "test_affected"
  201. ["orgtable"]=>
  202. string(13) "test_affected"
  203. ["def"]=>
  204. string(0) ""
  205. ["db"]=>
  206. string(%d) "%s"
  207. ["catalog"]=>
  208. string(%d) "%s"
  209. ["max_length"]=>
  210. int(0)
  211. ["length"]=>
  212. int(%d)
  213. ["charsetnr"]=>
  214. int(%d)
  215. ["flags"]=>
  216. int(0)
  217. ["type"]=>
  218. int(253)
  219. ["decimals"]=>
  220. int(0)
  221. }
  222. done!