v5:reference:adodb_assoc_case
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
reference:adodb_assoc_case [2015/12/04 15:54] – [ADODB_ASSOC_CASE] mnewnham | v5:reference:adodb_assoc_case [2022/06/08 16:14] (current) – [Usage] fix code samples to reflect correct initialization of ADODB_ASSOC_CASE dregad | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== ADODB_ASSOC_CASE ===== | + | ====== ADODB_ASSOC_CASE |
~~NOTOC~~ | ~~NOTOC~~ | ||
- | <WRAP right info 300px> | ||
- | == See Also == | ||
- | [[dictionary: | ||
- | </ | ||
- | The constant must be declared **before** including | ||
- | You can control the associative fetch case for certain drivers which behave differently. For the following drivers: | + | When returning data in **associative |
- | | + | It must be declared |
- | * [[database: | + | Being a constant, it is of course not possible to change its value later on. |
- | | + | |
- | * [[database: | + | Note that this setting has no effect on the casing of the actual data. |
- | * [[database: | + | |
- | | + | <WRAP info> |
- | + | Until ADOdb 5.20.14, the documentation contained several references to a global variable named '' | |
- | ADODB_ASSOC_CASE will by default generate recordsets where the field name keys are lower-cased. Use the constant ADODB_ASSOC_CASE | + | |
+ | **As of 5.20.15, the only supported method | ||
+ | </ | ||
- | ===== Constants | + | ===== Possible values |
^Name^Value^Description^ | ^Name^Value^Description^ | ||
|ADODB_ASSOC_CASE_LOWER|0|lowercase field names| | |ADODB_ASSOC_CASE_LOWER|0|lowercase field names| | ||
|ADODB_ASSOC_CASE_UPPER|1|uppercase field names| | |ADODB_ASSOC_CASE_UPPER|1|uppercase field names| | ||
- | |ADODB_ASSOC_CASE_NATIVE (Default)|2|use native-case field names| | + | |ADODB_ASSOC_CASE_NATIVE (Default)|2|native-case field names| |
+ | |||
+ | With the default behavior, '' | ||
+ | |||
+ | <WRAP tip> | ||
+ | When writing portable code, it is strongly recommended to choose either upper or lower case. | ||
+ | Relying on the native case default will likely cause compatibility issues, as there is no consistent casing across databases and some DBMS may returned mixed-case keys. | ||
+ | </ | ||
===== Usage ===== | ===== Usage ===== | ||
<code php> | <code php> | ||
- | DEFINE(ADODB_ASSOC_CASE, | + | require " |
- | require "adodb/adodb.inc.php"; | + | define(' |
+ | $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; | ||
- | /* | + | $db = ADONewConnection(' |
- | * connection assumed | + | $db-> |
- | */ | + | |
+ | print_r($db-> | ||
+ | |||
+ | /* Response is: | ||
- | $SQL = " | ||
- | $data = $db-> | ||
- | print_r($data); | ||
- | /* | ||
- | * Response is: | ||
| | ||
' | ' | ||
Line 44: | Line 47: | ||
' | ' | ||
) | ) | ||
- | ) | ||
- | |||
*/ | */ | ||
</ | </ | ||
or: | or: | ||
+ | |||
<code php> | <code php> | ||
- | DEFINE(ADODB_ASSOC_CASE, | + | require " |
- | require "adodb/adodb.inc.php"; | + | define(' |
+ | $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; | ||
- | /* | + | $db = ADONewConnection(' |
- | * connection assumed | + | $db-> |
- | */ | + | |
+ | print_r($db-> | ||
+ | |||
+ | /* Response is: | ||
- | $SQL = " | ||
- | $data = $db-> | ||
- | print_r($data); | ||
- | /* | ||
- | * Response is: | ||
| | ||
' | ' | ||
Line 69: | Line 70: | ||
' | ' | ||
) | ) | ||
- | ) | ||
- | |||
*/ | */ | ||
</ | </ | ||
Line 77: | Line 76: | ||
<code php> | <code php> | ||
- | DEFINE(ADODB_ASSOC_CASE, | + | require " |
- | require "adodb/adodb.inc.php"; | + | define(' |
+ | $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; | ||
- | /* | + | $db = ADONewConnection(' |
- | * connection assumed | + | $db-> |
- | */ | + | |
+ | print_r($db-> | ||
+ | |||
+ | /* Response is: | ||
- | $SQL = " | ||
- | $data = $db-> | ||
- | print_r($data); | ||
- | /* | ||
- | * Response is: | ||
| | ||
' | ' | ||
Line 95: | Line 93: | ||
' | ' | ||
) | ) | ||
- | ) | ||
- | |||
*/ | */ | ||
</ | </ |
v5/reference/adodb_assoc_case.1449240860.txt.gz · Last modified: 2017/04/21 11:32 (external edit)