fetch_array.phpt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. --TEST--
  2. oci_fetch_array()
  3. --SKIPIF--
  4. <?php
  5. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  6. require(dirname(__FILE__).'/skipif.inc');
  7. ?>
  8. --FILE--
  9. <?php
  10. require dirname(__FILE__)."/connect.inc";
  11. require dirname(__FILE__).'/create_table.inc';
  12. $insert_sql = "INSERT INTO ".$schema."".$table_name." (id, value) VALUES (1,1)";
  13. if (!($s = oci_parse($c, $insert_sql))) {
  14. die("oci_parse(insert) failed!\n");
  15. }
  16. for ($i = 0; $i<3; $i++) {
  17. if (!oci_execute($s)) {
  18. die("oci_execute(insert) failed!\n");
  19. }
  20. }
  21. if (!oci_commit($c)) {
  22. die("oci_commit() failed!\n");
  23. }
  24. echo "Test 1\n";
  25. $select_sql = "SELECT * FROM ".$schema."".$table_name."";
  26. if (!($s = oci_parse($c, $select_sql))) {
  27. die("oci_parse(select) failed!\n");
  28. }
  29. if (!oci_execute($s)) {
  30. die("oci_execute(select) failed!\n");
  31. }
  32. while ($row = oci_fetch_array($s)) {
  33. var_dump($row);
  34. }
  35. echo "Test 2\n";
  36. if (!oci_execute($s)) {
  37. die("oci_execute(select) failed!\n");
  38. }
  39. while ($row = oci_fetch_array($s, OCI_NUM)) {
  40. var_dump($row);
  41. }
  42. echo "Test 3\n";
  43. if (!oci_execute($s)) {
  44. die("oci_execute(select) failed!\n");
  45. }
  46. while ($row = oci_fetch_array($s, OCI_ASSOC)) {
  47. var_dump($row);
  48. }
  49. echo "Test 4\n";
  50. if (!oci_execute($s)) {
  51. die("oci_execute(select) failed!\n");
  52. }
  53. while ($row = oci_fetch_array($s, OCI_BOTH)) {
  54. var_dump($row);
  55. }
  56. echo "Test 5\n";
  57. if (!oci_execute($s)) {
  58. die("oci_execute(select) failed!\n");
  59. }
  60. while ($row = oci_fetch_array($s, OCI_RETURN_LOBS)) {
  61. var_dump($row);
  62. }
  63. echo "Test 6\n";
  64. if (!oci_execute($s)) {
  65. die("oci_execute(select) failed!\n");
  66. }
  67. while ($row = oci_fetch_array($s, OCI_RETURN_NULLS)) {
  68. var_dump($row);
  69. }
  70. echo "Test 7\n";
  71. if (!oci_execute($s)) {
  72. die("oci_execute(select) failed!\n");
  73. }
  74. while ($row = oci_fetch_array($s, OCI_NUM+OCI_RETURN_NULLS)) {
  75. var_dump($row);
  76. }
  77. require dirname(__FILE__).'/drop_table.inc';
  78. echo "Done\n";
  79. ?>
  80. --EXPECT--
  81. Test 1
  82. array(10) {
  83. [0]=>
  84. string(1) "1"
  85. ["ID"]=>
  86. string(1) "1"
  87. [1]=>
  88. string(1) "1"
  89. ["VALUE"]=>
  90. string(1) "1"
  91. [2]=>
  92. NULL
  93. ["BLOB"]=>
  94. NULL
  95. [3]=>
  96. NULL
  97. ["CLOB"]=>
  98. NULL
  99. [4]=>
  100. NULL
  101. ["STRING"]=>
  102. NULL
  103. }
  104. array(10) {
  105. [0]=>
  106. string(1) "1"
  107. ["ID"]=>
  108. string(1) "1"
  109. [1]=>
  110. string(1) "1"
  111. ["VALUE"]=>
  112. string(1) "1"
  113. [2]=>
  114. NULL
  115. ["BLOB"]=>
  116. NULL
  117. [3]=>
  118. NULL
  119. ["CLOB"]=>
  120. NULL
  121. [4]=>
  122. NULL
  123. ["STRING"]=>
  124. NULL
  125. }
  126. array(10) {
  127. [0]=>
  128. string(1) "1"
  129. ["ID"]=>
  130. string(1) "1"
  131. [1]=>
  132. string(1) "1"
  133. ["VALUE"]=>
  134. string(1) "1"
  135. [2]=>
  136. NULL
  137. ["BLOB"]=>
  138. NULL
  139. [3]=>
  140. NULL
  141. ["CLOB"]=>
  142. NULL
  143. [4]=>
  144. NULL
  145. ["STRING"]=>
  146. NULL
  147. }
  148. Test 2
  149. array(2) {
  150. [0]=>
  151. string(1) "1"
  152. [1]=>
  153. string(1) "1"
  154. }
  155. array(2) {
  156. [0]=>
  157. string(1) "1"
  158. [1]=>
  159. string(1) "1"
  160. }
  161. array(2) {
  162. [0]=>
  163. string(1) "1"
  164. [1]=>
  165. string(1) "1"
  166. }
  167. Test 3
  168. array(2) {
  169. ["ID"]=>
  170. string(1) "1"
  171. ["VALUE"]=>
  172. string(1) "1"
  173. }
  174. array(2) {
  175. ["ID"]=>
  176. string(1) "1"
  177. ["VALUE"]=>
  178. string(1) "1"
  179. }
  180. array(2) {
  181. ["ID"]=>
  182. string(1) "1"
  183. ["VALUE"]=>
  184. string(1) "1"
  185. }
  186. Test 4
  187. array(4) {
  188. [0]=>
  189. string(1) "1"
  190. ["ID"]=>
  191. string(1) "1"
  192. [1]=>
  193. string(1) "1"
  194. ["VALUE"]=>
  195. string(1) "1"
  196. }
  197. array(4) {
  198. [0]=>
  199. string(1) "1"
  200. ["ID"]=>
  201. string(1) "1"
  202. [1]=>
  203. string(1) "1"
  204. ["VALUE"]=>
  205. string(1) "1"
  206. }
  207. array(4) {
  208. [0]=>
  209. string(1) "1"
  210. ["ID"]=>
  211. string(1) "1"
  212. [1]=>
  213. string(1) "1"
  214. ["VALUE"]=>
  215. string(1) "1"
  216. }
  217. Test 5
  218. array(4) {
  219. [0]=>
  220. string(1) "1"
  221. ["ID"]=>
  222. string(1) "1"
  223. [1]=>
  224. string(1) "1"
  225. ["VALUE"]=>
  226. string(1) "1"
  227. }
  228. array(4) {
  229. [0]=>
  230. string(1) "1"
  231. ["ID"]=>
  232. string(1) "1"
  233. [1]=>
  234. string(1) "1"
  235. ["VALUE"]=>
  236. string(1) "1"
  237. }
  238. array(4) {
  239. [0]=>
  240. string(1) "1"
  241. ["ID"]=>
  242. string(1) "1"
  243. [1]=>
  244. string(1) "1"
  245. ["VALUE"]=>
  246. string(1) "1"
  247. }
  248. Test 6
  249. array(10) {
  250. [0]=>
  251. string(1) "1"
  252. ["ID"]=>
  253. string(1) "1"
  254. [1]=>
  255. string(1) "1"
  256. ["VALUE"]=>
  257. string(1) "1"
  258. [2]=>
  259. NULL
  260. ["BLOB"]=>
  261. NULL
  262. [3]=>
  263. NULL
  264. ["CLOB"]=>
  265. NULL
  266. [4]=>
  267. NULL
  268. ["STRING"]=>
  269. NULL
  270. }
  271. array(10) {
  272. [0]=>
  273. string(1) "1"
  274. ["ID"]=>
  275. string(1) "1"
  276. [1]=>
  277. string(1) "1"
  278. ["VALUE"]=>
  279. string(1) "1"
  280. [2]=>
  281. NULL
  282. ["BLOB"]=>
  283. NULL
  284. [3]=>
  285. NULL
  286. ["CLOB"]=>
  287. NULL
  288. [4]=>
  289. NULL
  290. ["STRING"]=>
  291. NULL
  292. }
  293. array(10) {
  294. [0]=>
  295. string(1) "1"
  296. ["ID"]=>
  297. string(1) "1"
  298. [1]=>
  299. string(1) "1"
  300. ["VALUE"]=>
  301. string(1) "1"
  302. [2]=>
  303. NULL
  304. ["BLOB"]=>
  305. NULL
  306. [3]=>
  307. NULL
  308. ["CLOB"]=>
  309. NULL
  310. [4]=>
  311. NULL
  312. ["STRING"]=>
  313. NULL
  314. }
  315. Test 7
  316. array(5) {
  317. [0]=>
  318. string(1) "1"
  319. [1]=>
  320. string(1) "1"
  321. [2]=>
  322. NULL
  323. [3]=>
  324. NULL
  325. [4]=>
  326. NULL
  327. }
  328. array(5) {
  329. [0]=>
  330. string(1) "1"
  331. [1]=>
  332. string(1) "1"
  333. [2]=>
  334. NULL
  335. [3]=>
  336. NULL
  337. [4]=>
  338. NULL
  339. }
  340. array(5) {
  341. [0]=>
  342. string(1) "1"
  343. [1]=>
  344. string(1) "1"
  345. [2]=>
  346. NULL
  347. [3]=>
  348. NULL
  349. [4]=>
  350. NULL
  351. }
  352. Done