ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:learn_fields:associative_key_case

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
v5:userguide:learn_fields:associative_key_case [2016/03/18 01:11] – created mnewnhamv5:userguide:learn_fields:associative_key_case [2019/05/08 13:36] (current) – [Associative Key Case] dregad
Line 1: Line 1:
-<- v5:userguide:learn_fields:introduction|Fetch Mode ^ v5:userguide:learn_fields:start_lesson|Start Of Lesson ^ v5:userguide:learn_fields:field_objects|Field Objects ->+<- v5:userguide:learn_fields:start_lesson|Fetch Mode ^ v5:userguide:learn_fields:start_lesson|Start Of Lesson ^ v5:userguide:learn_fields:field_objects|Field Objects ->
 ~~NOTOC~~ ~~NOTOC~~
 ====== Associative Key Case ====== ====== Associative Key Case ======
  
-If returning data in associative mode, it is important to choose early in the project whether to use upper case or lower case keys. Once that decision has been made, a consistent result can be expected. ADOdb controls the casing of the keys using a constant [[v5:reference:adodb_assoc_case|ADODB_ASSOC_CASE]]. +If returning data in associative mode, it is important to choose early in the project whether to use upper case or lower case keys. Once that decision has been made, a consistent result can be expected. ADOdb controls the casing of the keys using the ''[[v5:reference:adodb_assoc_case|ADODB_ASSOC_CASE]]'' constant
  
 The constant must be defined //**before**// the inclusion of the ADOdb libraries The constant must be defined //**before**// the inclusion of the ADOdb libraries
  
-There are 3 possible values:+There are 3 possible values: ''ADODB_ASSOC_CASE_LOWER'', ''ADODB_ASSOC_CASE_UPPER'' and ''ADODB_ASSOC_CASE_NATIVE'' (Default). Note that use of native case is not recommended when writing portable applications.
  
-===== Constants ===== +See ''[[v5:reference:adodb_assoc_case|ADODB_ASSOC_CASE]]'' in the reference manual for further information and usage examples.
-^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|+
  
-<code php> 
-DEFINE(ADODB_ASSOC_CASE,0); 
-require "adodb/adodb.inc.php"; 
- 
-$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; 
- 
-$sql = 'select * from some_table'; 
- 
-print_r($db->getAll($sql)); 
- 
-/* 
-* Returns 
-* 
-array(0=>array('col0'=>'val0', 
-               'col1'=>'val1', 
-               'col2'=>'val2', 
-               etc.... 
-               ) 
-*/ 
-</code> 
- 
-If we now set the value of ADODB_ASSOC_CASE to upper case, we obtain the following effect:         
- 
-<code php> 
-DEFINE(ADODB_ASSOC_CASE,1); 
-require "adodb/adodb.inc.php"; 
- 
-$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; 
- 
-$sql = 'select * from some_table'; 
- 
-print_r($db->getAll($sql)); 
- 
-/* 
-* Returns 
-* 
-array(0=>array('COL0'=>'val0', 
-               'COL1'=>'val1', 
-               'COL2'=>'val2', 
-               etc.... 
-               ) 
-*/ 
-</code> 
- 
-  * Note that setting the value of this variable has no effect on the casing of the values of the array 
-  * Use of **//ADODB_CASE_NATIVE//** is not recommended when writing portable applications, as there is no consistent casing across databases. Some DBMS may returned mixed-case keys. 
-  *  
- 
- 
-  
v5/userguide/learn_fields/associative_key_case.1458259893.txt.gz · Last modified: 2017/04/21 11:40 (external edit)