This is an old revision of the document!
ADODB_ASSOC_CASE
When returning data in associative fetch mode, the ADODB_ASSOC_CASE
constant gives control over the casing of the retrieved recordsets' fields.
It must be declared before inclusion of the ADOdb libraries (adodb.inc.php
), and being a constant it is of course not possible to change its value later on.
Note that this setting has no effect on the casing of the actual data.
Possible values
Name | Value | Description |
---|---|---|
ADODB_ASSOC_CASE_LOWER | 0 | lowercase field names |
ADODB_ASSOC_CASE_UPPER | 1 | uppercase field names |
ADODB_ASSOC_CASE_NATIVE (Default) | 2 | native-case field names |
The default behavior, ADODB_CASE_NATIVE
, lets the DBMS control the fields' casing (i.e. ADOdb returns them exactly as they are defined by the DBMS). However, when writing portable code, it is strongly recommended to choose a default behavior and stick to it, as there is no consistent casing across databases and some DBMS may returned mixed-case keys.
Usage
define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_LOWER); require "adodb.inc.php"; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; // $db Connection assumed print_r($db->getAll("SELECT accountNo, accountName FROM table")); /* Response is: [0]=>array('accountno'=>1, 'accountname'=>'The First Account' ), [1]=>array('accountno'=>2, 'accountname'=>'The Second Account' ) */
or:
define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_UPPER); require "adodb.inc.php"; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; // $db Connection assumed print_r($db->getAll("SELECT accountNo, accountName FROM table")); /* Response is: [0]=>array('ACCOUNTNO'=>1, 'ACCOUNTNAME'=>'The First Account' ), [1]=>array('ACCOUNTNO'=>2, 'ACCOUNTNAME'=>'The Second Account' ) */
or:
define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_NATIVE); require "adodb.inc.php"; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; // $db Connection assumed print_r($db->getAll("SELECT accountNo, accountName FROM table")); /* Response is: [0]=>array('accountNo'=>1, 'accountName'=>'The First Account' ), [1]=>array('accountNo'=>2, 'accountName'=>'The Second Account' ) */