tags:

views:

10

answers:

2

it fetches like this


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

)

How to get either case like

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

) 

or

Array
(
    [NAME] => ABC
    [AGE] => 33
    [GENDER] => M
    [CITY] => LA
    [STATE] => OH
)
+1  A: 
  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
A: 

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