v5:reference:adodb_assoc_case
This is an old revision of the document!
ADODB_ASSOC_CASE
See Also
The constant must be declared before including adodb.inc.php.
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
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 | use 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.1449241313.txt.gz · Last modified: 2017/04/21 11:32 (external edit)