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