ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:adodb_assoc_case

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
v5:reference:adodb_assoc_case [2019/05/08 13:17] – Rewrite and reformat, based also on 'Associative Key Case' page of 'Working With Fields' tutorial dregadv5:reference:adodb_assoc_case [2019/05/08 13:26] – Example usage: use constants instead of values, simplify code and define $ADODB_FETCH_MODE dregad
Line 20: Line 20:
 ===== Usage ===== ===== Usage =====
 <code php> <code php>
-define('ADODB_ASSOC_CASE',0); +define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_LOWER); 
-require "adodb/adodb.inc.php";+require "adodb.inc.php"
 +$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
  
-/+// $db Connection assumed 
- * connection assumed + 
-*/+print_r($db->getAll("SELECT accountNo, accountName FROM table")); 
 + 
 +/* Response is:
  
-$sql = "SELECT accountNo,accountName FROM table"; 
-$data = $db->getAll($sql); 
-print_r($data); 
-/* 
- * Response is: 
  [0]=>array('accountno'=>1,  [0]=>array('accountno'=>1,
             'accountname'=>'The First Account'             'accountname'=>'The First Account'
Line 38: Line 36:
             'accountname'=>'The Second Account'             'accountname'=>'The Second Account'
             )             )
-            )            
- 
 */ */
 </code> </code>
Line 45: Line 41:
 or: or:
 <code php> <code php>
-define('ADODB_ASSOC_CASE',1); +define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_UPPER); 
-require "adodb/adodb.inc.php";+require "adodb.inc.php"
 +$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
  
-/+// $db Connection assumed 
- * connection assumed + 
-*/+print_r($db->getAll("SELECT accountNo, accountName FROM table")); 
 + 
 +/* Response is:
  
-$sql = "SELECT accountNo,accountName FROM table"; 
-$data = $db->getAll($sql); 
-print_r($data); 
-/* 
- * Response is: 
  [0]=>array('ACCOUNTNO'=>1,  [0]=>array('ACCOUNTNO'=>1,
             'ACCOUNTNAME'=>'The First Account'             'ACCOUNTNAME'=>'The First Account'
Line 63: Line 57:
             'ACCOUNTNAME'=>'The Second Account'             'ACCOUNTNAME'=>'The Second Account'
             )             )
-            )            
- 
 */ */
 </code> </code>
Line 71: Line 63:
  
 <code php> <code php>
-define('ADODB_ASSOC_CASE',2); +define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_NATIVE); 
-require "adodb/adodb.inc.php";+require "adodb.inc.php"
 +$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
  
-/+// $db Connection assumed 
- * connection assumed + 
-*/+print_r($db->getAll("SELECT accountNo, accountName FROM table")); 
 + 
 +/* Response is:
  
-$sql = "SELECT accountNo,accountName FROM table"; 
-$data = $db->getAll($sql); 
-print_r($data); 
-/* 
- * Response is: 
  [0]=>array('accountNo'=>1,  [0]=>array('accountNo'=>1,
             'accountName'=>'The First Account'             'accountName'=>'The First Account'
Line 89: Line 79:
             'accountName'=>'The Second Account'             'accountName'=>'The Second Account'
             )             )
-            )            
- 
 */ */
 </code> </code>
v5/reference/adodb_assoc_case.txt · Last modified: 2022/06/08 16:14 by dregad