4

ADOdb fetchRow output:

Array
(
 [0] => ABC
    [NAME] => ABC
    [1] => 33
 [AGE] => 33
    [3] => M
 [GENDER] => M
    [4] => LA
 [CITY] => LA
    [5] => OH
 [STATE] => OH
)

How can I get the number-index only output:

Array 
(
 [0] => ABC
 [1] => 33
 [2] => M
 [3] => LA
 [4] => OH

) 

Or the name-index only output? :

Array
(
    [NAME] => ABC
    [AGE] => 33
    [GENDER] => M
    [CITY] => LA
    [STATE] => OH
)
Pacerier
  • 86,231
  • 106
  • 366
  • 634
maxjackie
  • 22,386
  • 6
  • 29
  • 37

2 Answers2

6
  1. Numeric indexes – use $connection->SetFetchMode(ADODB_FETCH_NUM).

  2. Associative indexes – the keys of the array are the names of the fields (in upper-case). Use $connection->SetFetchMode(ADODB_FETCH_ASSOC).

  3. Both numeric and associative indexes – use $connection->SetFetchMode(ADODB_FETCH_BOTH).

The default is ADODB_FETCH_BOTH for Oracle.

maxjackie
  • 22,386
  • 6
  • 29
  • 37
0

Respectively

$ADODB_FETCH_MODE = ADODB_FETCH_NUM;

and

$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;

From the manual:

If no fetch mode is predefined, the fetch mode defaults to ADODB_FETCH_DEFAULT. The behaviour of this default mode varies from driver to driver, so do not rely on ADODB_FETCH_DEFAULT. For portability, we recommend sticking to ADODB_FETCH_NUM or ADODB_FETCH_ASSOC. Many drivers do not support ADODB_FETCH_BOTH.

djn
  • 3,950
  • 22
  • 21