From 719348d3ba11ffbfa79720ae5a5e3760c4a3644d Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Thu, 14 May 2015 04:10:04 +0200 Subject: New method ADORecordSet::AssocCaseConvertFunction() - Avoid code duplication - optimize ADORecordSet_assoc_postgres7::_updatefields() --- drivers/adodb-postgres7.inc.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'drivers/adodb-postgres7.inc.php') 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; } -- cgit v1.3