fetch_array.phpt 4.7 KB

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