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(dirname(__FILE__)."/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--EXPECTF-- 129None 130int(4) 131array(2) { 132 [%u|b%"ID"]=> 133 array(4) { 134 [0]=> 135 %unicode|string%(1) "1" 136 [1]=> 137 %unicode|string%(1) "2" 138 [2]=> 139 %unicode|string%(1) "3" 140 [3]=> 141 %unicode|string%(1) "4" 142 } 143 [%u|b%"VALUE"]=> 144 array(4) { 145 [0]=> 146 %unicode|string%(2) "-1" 147 [1]=> 148 %unicode|string%(2) "-2" 149 [2]=> 150 %unicode|string%(2) "-3" 151 [3]=> 152 %unicode|string%(2) "-4" 153 } 154} 155OCI_ASSOC 156int(4) 157array(2) { 158 [%u|b%"ID"]=> 159 array(4) { 160 [0]=> 161 %unicode|string%(1) "1" 162 [1]=> 163 %unicode|string%(1) "2" 164 [2]=> 165 %unicode|string%(1) "3" 166 [3]=> 167 %unicode|string%(1) "4" 168 } 169 [%u|b%"VALUE"]=> 170 array(4) { 171 [0]=> 172 %unicode|string%(2) "-1" 173 [1]=> 174 %unicode|string%(2) "-2" 175 [2]=> 176 %unicode|string%(2) "-3" 177 [3]=> 178 %unicode|string%(2) "-4" 179 } 180} 181OCI_FETCHSTATEMENT_BY_COLUMN 182int(4) 183array(2) { 184 [%u|b%"ID"]=> 185 array(4) { 186 [0]=> 187 %unicode|string%(1) "1" 188 [1]=> 189 %unicode|string%(1) "2" 190 [2]=> 191 %unicode|string%(1) "3" 192 [3]=> 193 %unicode|string%(1) "4" 194 } 195 [%u|b%"VALUE"]=> 196 array(4) { 197 [0]=> 198 %unicode|string%(2) "-1" 199 [1]=> 200 %unicode|string%(2) "-2" 201 [2]=> 202 %unicode|string%(2) "-3" 203 [3]=> 204 %unicode|string%(2) "-4" 205 } 206} 207OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC 208int(4) 209array(2) { 210 [%u|b%"ID"]=> 211 array(4) { 212 [0]=> 213 %unicode|string%(1) "1" 214 [1]=> 215 %unicode|string%(1) "2" 216 [2]=> 217 %unicode|string%(1) "3" 218 [3]=> 219 %unicode|string%(1) "4" 220 } 221 [%u|b%"VALUE"]=> 222 array(4) { 223 [0]=> 224 %unicode|string%(2) "-1" 225 [1]=> 226 %unicode|string%(2) "-2" 227 [2]=> 228 %unicode|string%(2) "-3" 229 [3]=> 230 %unicode|string%(2) "-4" 231 } 232} 233OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM 234int(4) 235array(2) { 236 [0]=> 237 array(4) { 238 [0]=> 239 %unicode|string%(1) "1" 240 [1]=> 241 %unicode|string%(1) "2" 242 [2]=> 243 %unicode|string%(1) "3" 244 [3]=> 245 %unicode|string%(1) "4" 246 } 247 [1]=> 248 array(4) { 249 [0]=> 250 %unicode|string%(2) "-1" 251 [1]=> 252 %unicode|string%(2) "-2" 253 [2]=> 254 %unicode|string%(2) "-3" 255 [3]=> 256 %unicode|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 %unicode|string%(1) "1" 266 [1]=> 267 %unicode|string%(1) "2" 268 [2]=> 269 %unicode|string%(1) "3" 270 [3]=> 271 %unicode|string%(1) "4" 272 } 273 [1]=> 274 array(4) { 275 [0]=> 276 %unicode|string%(2) "-1" 277 [1]=> 278 %unicode|string%(2) "-2" 279 [2]=> 280 %unicode|string%(2) "-3" 281 [3]=> 282 %unicode|string%(2) "-4" 283 } 284} 285OCI_FETCHSTATEMENT_BY_ROW 286int(4) 287array(4) { 288 [0]=> 289 array(2) { 290 [%u|b%"ID"]=> 291 %unicode|string%(1) "1" 292 [%u|b%"VALUE"]=> 293 %unicode|string%(2) "-1" 294 } 295 [1]=> 296 array(2) { 297 [%u|b%"ID"]=> 298 %unicode|string%(1) "2" 299 [%u|b%"VALUE"]=> 300 %unicode|string%(2) "-2" 301 } 302 [2]=> 303 array(2) { 304 [%u|b%"ID"]=> 305 %unicode|string%(1) "3" 306 [%u|b%"VALUE"]=> 307 %unicode|string%(2) "-3" 308 } 309 [3]=> 310 array(2) { 311 [%u|b%"ID"]=> 312 %unicode|string%(1) "4" 313 [%u|b%"VALUE"]=> 314 %unicode|string%(2) "-4" 315 } 316} 317OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC 318int(4) 319array(4) { 320 [0]=> 321 array(2) { 322 [%u|b%"ID"]=> 323 %unicode|string%(1) "1" 324 [%u|b%"VALUE"]=> 325 %unicode|string%(2) "-1" 326 } 327 [1]=> 328 array(2) { 329 [%u|b%"ID"]=> 330 %unicode|string%(1) "2" 331 [%u|b%"VALUE"]=> 332 %unicode|string%(2) "-2" 333 } 334 [2]=> 335 array(2) { 336 [%u|b%"ID"]=> 337 %unicode|string%(1) "3" 338 [%u|b%"VALUE"]=> 339 %unicode|string%(2) "-3" 340 } 341 [3]=> 342 array(2) { 343 [%u|b%"ID"]=> 344 %unicode|string%(1) "4" 345 [%u|b%"VALUE"]=> 346 %unicode|string%(2) "-4" 347 } 348} 349OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN 350int(4) 351array(4) { 352 [0]=> 353 array(2) { 354 [%u|b%"ID"]=> 355 %unicode|string%(1) "1" 356 [%u|b%"VALUE"]=> 357 %unicode|string%(2) "-1" 358 } 359 [1]=> 360 array(2) { 361 [%u|b%"ID"]=> 362 %unicode|string%(1) "2" 363 [%u|b%"VALUE"]=> 364 %unicode|string%(2) "-2" 365 } 366 [2]=> 367 array(2) { 368 [%u|b%"ID"]=> 369 %unicode|string%(1) "3" 370 [%u|b%"VALUE"]=> 371 %unicode|string%(2) "-3" 372 } 373 [3]=> 374 array(2) { 375 [%u|b%"ID"]=> 376 %unicode|string%(1) "4" 377 [%u|b%"VALUE"]=> 378 %unicode|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 [%u|b%"ID"]=> 387 %unicode|string%(1) "1" 388 [%u|b%"VALUE"]=> 389 %unicode|string%(2) "-1" 390 } 391 [1]=> 392 array(2) { 393 [%u|b%"ID"]=> 394 %unicode|string%(1) "2" 395 [%u|b%"VALUE"]=> 396 %unicode|string%(2) "-2" 397 } 398 [2]=> 399 array(2) { 400 [%u|b%"ID"]=> 401 %unicode|string%(1) "3" 402 [%u|b%"VALUE"]=> 403 %unicode|string%(2) "-3" 404 } 405 [3]=> 406 array(2) { 407 [%u|b%"ID"]=> 408 %unicode|string%(1) "4" 409 [%u|b%"VALUE"]=> 410 %unicode|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 %unicode|string%(1) "1" 420 [1]=> 421 %unicode|string%(2) "-1" 422 } 423 [1]=> 424 array(2) { 425 [0]=> 426 %unicode|string%(1) "2" 427 [1]=> 428 %unicode|string%(2) "-2" 429 } 430 [2]=> 431 array(2) { 432 [0]=> 433 %unicode|string%(1) "3" 434 [1]=> 435 %unicode|string%(2) "-3" 436 } 437 [3]=> 438 array(2) { 439 [0]=> 440 %unicode|string%(1) "4" 441 [1]=> 442 %unicode|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 %unicode|string%(1) "1" 452 [1]=> 453 %unicode|string%(2) "-1" 454 } 455 [1]=> 456 array(2) { 457 [0]=> 458 %unicode|string%(1) "2" 459 [1]=> 460 %unicode|string%(2) "-2" 461 } 462 [2]=> 463 array(2) { 464 [0]=> 465 %unicode|string%(1) "3" 466 [1]=> 467 %unicode|string%(2) "-3" 468 } 469 [3]=> 470 array(2) { 471 [0]=> 472 %unicode|string%(1) "4" 473 [1]=> 474 %unicode|string%(2) "-4" 475 } 476} 477OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM 478int(4) 479array(4) { 480 [0]=> 481 array(2) { 482 [0]=> 483 %unicode|string%(1) "1" 484 [1]=> 485 %unicode|string%(2) "-1" 486 } 487 [1]=> 488 array(2) { 489 [0]=> 490 %unicode|string%(1) "2" 491 [1]=> 492 %unicode|string%(2) "-2" 493 } 494 [2]=> 495 array(2) { 496 [0]=> 497 %unicode|string%(1) "3" 498 [1]=> 499 %unicode|string%(2) "-3" 500 } 501 [3]=> 502 array(2) { 503 [0]=> 504 %unicode|string%(1) "4" 505 [1]=> 506 %unicode|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 %unicode|string%(1) "1" 516 [1]=> 517 %unicode|string%(2) "-1" 518 } 519 [1]=> 520 array(2) { 521 [0]=> 522 %unicode|string%(1) "2" 523 [1]=> 524 %unicode|string%(2) "-2" 525 } 526 [2]=> 527 array(2) { 528 [0]=> 529 %unicode|string%(1) "3" 530 [1]=> 531 %unicode|string%(2) "-3" 532 } 533 [3]=> 534 array(2) { 535 [0]=> 536 %unicode|string%(1) "4" 537 [1]=> 538 %unicode|string%(2) "-4" 539 } 540} 541OCI_NUM 542int(4) 543array(2) { 544 [0]=> 545 array(4) { 546 [0]=> 547 %unicode|string%(1) "1" 548 [1]=> 549 %unicode|string%(1) "2" 550 [2]=> 551 %unicode|string%(1) "3" 552 [3]=> 553 %unicode|string%(1) "4" 554 } 555 [1]=> 556 array(4) { 557 [0]=> 558 %unicode|string%(2) "-1" 559 [1]=> 560 %unicode|string%(2) "-2" 561 [2]=> 562 %unicode|string%(2) "-3" 563 [3]=> 564 %unicode|string%(2) "-4" 565 } 566} 567OCI_NUM|OCI_ASSOC 568int(4) 569array(2) { 570 [0]=> 571 array(4) { 572 [0]=> 573 %unicode|string%(1) "1" 574 [1]=> 575 %unicode|string%(1) "2" 576 [2]=> 577 %unicode|string%(1) "3" 578 [3]=> 579 %unicode|string%(1) "4" 580 } 581 [1]=> 582 array(4) { 583 [0]=> 584 %unicode|string%(2) "-1" 585 [1]=> 586 %unicode|string%(2) "-2" 587 [2]=> 588 %unicode|string%(2) "-3" 589 [3]=> 590 %unicode|string%(2) "-4" 591 } 592} 593Done 594