ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:adodb_assoc_case

This is an old revision of the document!


ADODB_ASSOC_CASE

See Also

metaCasing

The constant must be declared before including adodb.inc.php.

You can control the associative fetch case for certain drivers which behave differently. For the following drivers:

ADODB_ASSOC_CASE will by default generate recordsets where the field name keys are lower-cased. Use the constant ADODB_ASSOC_CASE to change the case of the keys. There are 3 possible values:

Constants

NameValueDescription
ADODB_ASSOC_CASE_LOWER0lowercase field names
ADODB_ASSOC_CASE_UPPER1uppercase field names
ADODB_ASSOC_CASE_NATIVE (Default)2use native-case field names

Usage

DEFINE(ADODB_ASSOC_CASE,0);
require "adodb/adodb.inc.php";
 
/*
 * connection assumed
*/
 
$SQL = "SELECT accountNo,accountName FROM table";
$data = $db->getAll($SQL);
print_r($data);
/*
 * Response is:
 [0]=>array('accountno'=>1,
            'accountname'=>'The First Account'
            ),
 [1]=>array('accountno'=>2,
            'accountname'=>'The Second Account'
            )
            )           
 
*/

or:

DEFINE(ADODB_ASSOC_CASE,1);
require "adodb/adodb.inc.php";
 
/*
 * connection assumed
*/
 
$SQL = "SELECT accountNo,accountName FROM table";
$data = $db->getAll($SQL);
print_r($data);
/*
 * Response is:
 [0]=>array('ACCOUNTNO'=>1,
            'ACCOUNTNAME'=>'The First Account'
            ),
 [1]=>array('ACCOUNTNO'=>2,
            'ACCOUNTNAME'=>'The Second Account'
            )
            )           
 
*/

or:

DEFINE(ADODB_ASSOC_CASE,3);
require "adodb/adodb.inc.php";
 
/*
 * connection assumed
*/
 
$SQL = "SELECT accountNo,accountName FROM table";
$data = $db->getAll($SQL);
print_r($data);
/*
 * Response is:
 [0]=>array('accountNo'=>1,
            'accountName'=>'The First Account'
            ),
 [1]=>array('accountNo'=>2,
            'accountName'=>'The Second Account'
            )
            )           
 
*/
v5/reference/adodb_assoc_case.1449240834.txt.gz · Last modified: 2017/04/21 11:32 (external edit)