v5:userguide:learn_fields:start_lesson
Fields And Fields Objects
Formatting Of Returned Data
ADOdb provides a number of methods for controlling returned data. The data may be represented as arrays, both numeric and associative, and as objects.
$ADODB_FETCH_MODE
The global variable $ADODB_FETCH_MODE controls how the keys of the arrays containing the returned data are presented. The variable should be set before the query is executed. In addition to the variable, the constants ADODB_FETCH_NUM,ADODB_FETCH_ASSOC,ADODB_FETCH_BOTH and ADODB_FETCH_NATIVE are available to help. The available values are described as follows:
Name | Value | Description |
---|---|---|
ADODB_FETCH_DEFAULT | 0 | The recordset is returned in the default provided by the PHP driver. Use of this value is not recommended if writing cross-database applications |
ADODB_FETCH_NUM | 1 | The recordset is returned as a numeric array |
ADODB_FETCH_ASSOC | 2 | The recordset is returned as an associative array |
ADODB_FETCH_BOTH | 3 | The record is returned as both a numeric and associative arrays. Not supported in some databases |
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
returns:
array([0] =>'v0', [1] =>'v1', [2] =>'v2', etc.... )
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
returns:
array(['col0'] =>'v0', ['col1'] =>'v1', ['col2'] => 'v2', etc.....
)
$ADODB_FETCH_MODE = ADODB_FETCH_BOTH;
returns:
array([0] = 'v0', ['col0'] =>'v0', [1] = 'v1', ['col1'] =>'v1', [2] => 'v2', ['col2'] => 'v2', etc.....
)
v5/userguide/learn_fields/start_lesson.txt · Last modified: 2016/03/18 00:32 by mnewnham