1--TEST-- 2oci_fetch_all() - all combinations of flags 3--EXTENSIONS-- 4oci8 5--SKIPIF-- 6<?php 7require_once 'skipifconnectfailure.inc'; 8?> 9--FILE-- 10<?php 11 12require __DIR__.'/connect.inc'; 13 14// Initialize 15 16$stmtarray = array( 17 "drop table fetch_all3_tab", 18 "create table fetch_all3_tab (id number, value number)", 19); 20 21oci8_test_sql_execute($c, $stmtarray); 22 23$insert_sql = "insert into fetch_all3_tab (id, value) values (:idbv,:vbv)"; 24$s = oci_parse($c, $insert_sql); 25oci_bind_by_name($s, ":idbv", $idbv, -1, SQLT_INT); 26oci_bind_by_name($s, ":vbv", $vbv, -1, SQLT_INT); 27 28for ($i = 1; $i <= 4; $i++) { 29 $idbv = $i; 30 $vbv = -$i; 31 oci_execute($s, OCI_DEFAULT); 32} 33 34oci_commit($c); 35 36// Run Test 37 38$select_sql = "select id, value from fetch_all3_tab order by id"; 39 40$s = oci_parse($c, $select_sql); 41 42echo "None\n"; 43oci_execute($s); 44var_dump(oci_fetch_all($s, $all, 0, -1)); 45var_dump($all); 46 47echo "OCI_ASSOC\n"; 48oci_execute($s); 49var_dump(oci_fetch_all($s, $all, 0, -1, OCI_ASSOC)); 50var_dump($all); 51 52echo "OCI_FETCHSTATEMENT_BY_COLUMN\n"; 53oci_execute($s); 54var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_COLUMN)); 55var_dump($all); 56 57echo "OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC\n"; 58oci_execute($s); 59var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC)); 60var_dump($all); 61 62echo "OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM\n"; 63oci_execute($s); 64var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM)); 65var_dump($all); 66 67echo "OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC\n"; 68oci_execute($s); 69var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC)); 70var_dump($all); 71 72echo "OCI_FETCHSTATEMENT_BY_ROW\n"; 73oci_execute($s); 74var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW)); 75var_dump($all); 76 77echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC\n"; 78oci_execute($s); 79var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC)); 80var_dump($all); 81 82echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN\n"; 83oci_execute($s); 84var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN)); 85var_dump($all); 86 87echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC\n"; 88oci_execute($s); 89var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC)); 90var_dump($all); 91 92echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM\n"; 93oci_execute($s); 94var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM)); 95var_dump($all); 96 97echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC\n"; 98oci_execute($s); 99var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC)); 100var_dump($all); 101 102echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM\n"; 103oci_execute($s); 104var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM)); 105var_dump($all); 106 107echo "OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM|OCI_ASSOC\n"; 108oci_execute($s); 109var_dump(oci_fetch_all($s, $all, 0, -1, OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM|OCI_ASSOC)); 110var_dump($all); 111 112echo "OCI_NUM\n"; 113oci_execute($s); 114var_dump(oci_fetch_all($s, $all, 0, -1, OCI_NUM)); 115var_dump($all); 116 117echo "OCI_NUM|OCI_ASSOC\n"; 118oci_execute($s); 119var_dump(oci_fetch_all($s, $all, 0, -1, OCI_NUM|OCI_ASSOC)); 120var_dump($all); 121 122// Cleanup 123 124$stmtarray = array( 125 "drop table fetch_all3_tab" 126); 127 128oci8_test_sql_execute($c, $stmtarray); 129 130echo "Done\n"; 131?> 132--EXPECT-- 133None 134int(4) 135array(2) { 136 ["ID"]=> 137 array(4) { 138 [0]=> 139 string(1) "1" 140 [1]=> 141 string(1) "2" 142 [2]=> 143 string(1) "3" 144 [3]=> 145 string(1) "4" 146 } 147 ["VALUE"]=> 148 array(4) { 149 [0]=> 150 string(2) "-1" 151 [1]=> 152 string(2) "-2" 153 [2]=> 154 string(2) "-3" 155 [3]=> 156 string(2) "-4" 157 } 158} 159OCI_ASSOC 160int(4) 161array(2) { 162 ["ID"]=> 163 array(4) { 164 [0]=> 165 string(1) "1" 166 [1]=> 167 string(1) "2" 168 [2]=> 169 string(1) "3" 170 [3]=> 171 string(1) "4" 172 } 173 ["VALUE"]=> 174 array(4) { 175 [0]=> 176 string(2) "-1" 177 [1]=> 178 string(2) "-2" 179 [2]=> 180 string(2) "-3" 181 [3]=> 182 string(2) "-4" 183 } 184} 185OCI_FETCHSTATEMENT_BY_COLUMN 186int(4) 187array(2) { 188 ["ID"]=> 189 array(4) { 190 [0]=> 191 string(1) "1" 192 [1]=> 193 string(1) "2" 194 [2]=> 195 string(1) "3" 196 [3]=> 197 string(1) "4" 198 } 199 ["VALUE"]=> 200 array(4) { 201 [0]=> 202 string(2) "-1" 203 [1]=> 204 string(2) "-2" 205 [2]=> 206 string(2) "-3" 207 [3]=> 208 string(2) "-4" 209 } 210} 211OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC 212int(4) 213array(2) { 214 ["ID"]=> 215 array(4) { 216 [0]=> 217 string(1) "1" 218 [1]=> 219 string(1) "2" 220 [2]=> 221 string(1) "3" 222 [3]=> 223 string(1) "4" 224 } 225 ["VALUE"]=> 226 array(4) { 227 [0]=> 228 string(2) "-1" 229 [1]=> 230 string(2) "-2" 231 [2]=> 232 string(2) "-3" 233 [3]=> 234 string(2) "-4" 235 } 236} 237OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM 238int(4) 239array(2) { 240 [0]=> 241 array(4) { 242 [0]=> 243 string(1) "1" 244 [1]=> 245 string(1) "2" 246 [2]=> 247 string(1) "3" 248 [3]=> 249 string(1) "4" 250 } 251 [1]=> 252 array(4) { 253 [0]=> 254 string(2) "-1" 255 [1]=> 256 string(2) "-2" 257 [2]=> 258 string(2) "-3" 259 [3]=> 260 string(2) "-4" 261 } 262} 263OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC 264int(4) 265array(2) { 266 [0]=> 267 array(4) { 268 [0]=> 269 string(1) "1" 270 [1]=> 271 string(1) "2" 272 [2]=> 273 string(1) "3" 274 [3]=> 275 string(1) "4" 276 } 277 [1]=> 278 array(4) { 279 [0]=> 280 string(2) "-1" 281 [1]=> 282 string(2) "-2" 283 [2]=> 284 string(2) "-3" 285 [3]=> 286 string(2) "-4" 287 } 288} 289OCI_FETCHSTATEMENT_BY_ROW 290int(4) 291array(4) { 292 [0]=> 293 array(2) { 294 ["ID"]=> 295 string(1) "1" 296 ["VALUE"]=> 297 string(2) "-1" 298 } 299 [1]=> 300 array(2) { 301 ["ID"]=> 302 string(1) "2" 303 ["VALUE"]=> 304 string(2) "-2" 305 } 306 [2]=> 307 array(2) { 308 ["ID"]=> 309 string(1) "3" 310 ["VALUE"]=> 311 string(2) "-3" 312 } 313 [3]=> 314 array(2) { 315 ["ID"]=> 316 string(1) "4" 317 ["VALUE"]=> 318 string(2) "-4" 319 } 320} 321OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC 322int(4) 323array(4) { 324 [0]=> 325 array(2) { 326 ["ID"]=> 327 string(1) "1" 328 ["VALUE"]=> 329 string(2) "-1" 330 } 331 [1]=> 332 array(2) { 333 ["ID"]=> 334 string(1) "2" 335 ["VALUE"]=> 336 string(2) "-2" 337 } 338 [2]=> 339 array(2) { 340 ["ID"]=> 341 string(1) "3" 342 ["VALUE"]=> 343 string(2) "-3" 344 } 345 [3]=> 346 array(2) { 347 ["ID"]=> 348 string(1) "4" 349 ["VALUE"]=> 350 string(2) "-4" 351 } 352} 353OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN 354int(4) 355array(4) { 356 [0]=> 357 array(2) { 358 ["ID"]=> 359 string(1) "1" 360 ["VALUE"]=> 361 string(2) "-1" 362 } 363 [1]=> 364 array(2) { 365 ["ID"]=> 366 string(1) "2" 367 ["VALUE"]=> 368 string(2) "-2" 369 } 370 [2]=> 371 array(2) { 372 ["ID"]=> 373 string(1) "3" 374 ["VALUE"]=> 375 string(2) "-3" 376 } 377 [3]=> 378 array(2) { 379 ["ID"]=> 380 string(1) "4" 381 ["VALUE"]=> 382 string(2) "-4" 383 } 384} 385OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC 386int(4) 387array(4) { 388 [0]=> 389 array(2) { 390 ["ID"]=> 391 string(1) "1" 392 ["VALUE"]=> 393 string(2) "-1" 394 } 395 [1]=> 396 array(2) { 397 ["ID"]=> 398 string(1) "2" 399 ["VALUE"]=> 400 string(2) "-2" 401 } 402 [2]=> 403 array(2) { 404 ["ID"]=> 405 string(1) "3" 406 ["VALUE"]=> 407 string(2) "-3" 408 } 409 [3]=> 410 array(2) { 411 ["ID"]=> 412 string(1) "4" 413 ["VALUE"]=> 414 string(2) "-4" 415 } 416} 417OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM 418int(4) 419array(4) { 420 [0]=> 421 array(2) { 422 [0]=> 423 string(1) "1" 424 [1]=> 425 string(2) "-1" 426 } 427 [1]=> 428 array(2) { 429 [0]=> 430 string(1) "2" 431 [1]=> 432 string(2) "-2" 433 } 434 [2]=> 435 array(2) { 436 [0]=> 437 string(1) "3" 438 [1]=> 439 string(2) "-3" 440 } 441 [3]=> 442 array(2) { 443 [0]=> 444 string(1) "4" 445 [1]=> 446 string(2) "-4" 447 } 448} 449OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC 450int(4) 451array(4) { 452 [0]=> 453 array(2) { 454 [0]=> 455 string(1) "1" 456 [1]=> 457 string(2) "-1" 458 } 459 [1]=> 460 array(2) { 461 [0]=> 462 string(1) "2" 463 [1]=> 464 string(2) "-2" 465 } 466 [2]=> 467 array(2) { 468 [0]=> 469 string(1) "3" 470 [1]=> 471 string(2) "-3" 472 } 473 [3]=> 474 array(2) { 475 [0]=> 476 string(1) "4" 477 [1]=> 478 string(2) "-4" 479 } 480} 481OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM 482int(4) 483array(4) { 484 [0]=> 485 array(2) { 486 [0]=> 487 string(1) "1" 488 [1]=> 489 string(2) "-1" 490 } 491 [1]=> 492 array(2) { 493 [0]=> 494 string(1) "2" 495 [1]=> 496 string(2) "-2" 497 } 498 [2]=> 499 array(2) { 500 [0]=> 501 string(1) "3" 502 [1]=> 503 string(2) "-3" 504 } 505 [3]=> 506 array(2) { 507 [0]=> 508 string(1) "4" 509 [1]=> 510 string(2) "-4" 511 } 512} 513OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM|OCI_ASSOC 514int(4) 515array(4) { 516 [0]=> 517 array(2) { 518 [0]=> 519 string(1) "1" 520 [1]=> 521 string(2) "-1" 522 } 523 [1]=> 524 array(2) { 525 [0]=> 526 string(1) "2" 527 [1]=> 528 string(2) "-2" 529 } 530 [2]=> 531 array(2) { 532 [0]=> 533 string(1) "3" 534 [1]=> 535 string(2) "-3" 536 } 537 [3]=> 538 array(2) { 539 [0]=> 540 string(1) "4" 541 [1]=> 542 string(2) "-4" 543 } 544} 545OCI_NUM 546int(4) 547array(2) { 548 [0]=> 549 array(4) { 550 [0]=> 551 string(1) "1" 552 [1]=> 553 string(1) "2" 554 [2]=> 555 string(1) "3" 556 [3]=> 557 string(1) "4" 558 } 559 [1]=> 560 array(4) { 561 [0]=> 562 string(2) "-1" 563 [1]=> 564 string(2) "-2" 565 [2]=> 566 string(2) "-3" 567 [3]=> 568 string(2) "-4" 569 } 570} 571OCI_NUM|OCI_ASSOC 572int(4) 573array(2) { 574 [0]=> 575 array(4) { 576 [0]=> 577 string(1) "1" 578 [1]=> 579 string(1) "2" 580 [2]=> 581 string(1) "3" 582 [3]=> 583 string(1) "4" 584 } 585 [1]=> 586 array(4) { 587 [0]=> 588 string(2) "-1" 589 [1]=> 590 string(2) "-2" 591 [2]=> 592 string(2) "-3" 593 [3]=> 594 string(2) "-4" 595 } 596} 597Done 598