diff options
| -rw-r--r-- | adodb.inc.php | 31 | ||||
| -rw-r--r-- | drivers/adodb-postgres7.inc.php | 21 |
2 files changed, 32 insertions, 20 deletions
diff --git a/adodb.inc.php b/adodb.inc.php index e46c0a00..d90775f7 100644 --- a/adodb.inc.php +++ b/adodb.inc.php @@ -3729,6 +3729,25 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1 } /** + * Defines the function to use for table fields case conversion + * depending on ADODB_ASSOC_CASE + * @return string strtolower/strtoupper or false if no conversion needed + */ + protected function AssocCaseConvertFunction($case = ADODB_ASSOC_CASE) { + if($this->fetchMode & ADODB_FETCH_ASSOC) { + switch($case) { + case ADODB_ASSOC_CASE_UPPER: + return 'strtoupper'; + case ADODB_ASSOC_CASE_LOWER: + return 'strtolower'; + case ADODB_ASSOC_CASE_NATIVE: + default: + return false; + } + } + } + + /** * Builds the bind array associating keys to recordset fields * * @param int $upper Case for the array keys, defaults to uppercase @@ -3741,17 +3760,7 @@ http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_1 $this->bind = array(); // Define case conversion function for ASSOC fetch mode - $fn_change_case = false; - if($this->fetchMode & ADODB_FETCH_ASSOC) { - switch($upper) { - case ADODB_ASSOC_CASE_UPPER: - $fn_change_case = 'strtoupper'; - break; - case ADODB_ASSOC_CASE_LOWER: - $fn_change_case = 'strtolower'; - break; - } - } + $fn_change_case = $this->AssocCaseConvertFunction($upper); // Build the bind array for ($i=0; $i < $this->_numOfFields; $i++) { diff --git a/drivers/adodb-postgres7.inc.php b/drivers/adodb-postgres7.inc.php index 5a975797..2ff70157 100644 --- a/drivers/adodb-postgres7.inc.php +++ b/drivers/adodb-postgres7.inc.php @@ -358,22 +358,25 @@ class ADORecordSet_assoc_postgres7 extends ADORecordSet_postgres64{ return (is_array($this->fields)); } - // Create associative array + /** + * Convert case of field names associative array, if needed + * @return void + */ function _updatefields() { - if (ADODB_ASSOC_CASE == 2) return; // native + $fn_change_case = $this->AssocCaseConvertFunction(); + if(!$fn_change_case) { + // No conversion needed + return; + } $arr = array(); - $lowercase = (ADODB_ASSOC_CASE == 0); foreach($this->fields as $k => $v) { - if (is_integer($k)) $arr[$k] = $v; - else { - if ($lowercase) - $arr[strtolower($k)] = $v; - else - $arr[strtoupper($k)] = $v; + if (!is_integer($k)) { + $k = $fn_change_case($k); } + $arr[$k] = $v; } $this->fields = $arr; } |
