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. It is not possible to change the casing of recordset keys during a procedure.

The constant ADODB_ASSOC_CASE controls the key casing of retrieved recordsets when the fetch mode is set to associative. The default behavior for retrieval is controlled by the DBMS. When writing portable code, it is important to choose a default behavior and always use it.

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.1452648712.txt.gz · Last modified: 2017/04/21 11:32 (external edit)