| 61 | | if ( ! is_numeric($func)) { |
| 62 | | $a = explode('.', $func); |
| 63 | | |
| 64 | | if (count($a) > 1) { |
| 65 | | $field = array_pop($a); |
| 66 | | $reference = implode('.', $a); |
| 67 | | $map = $this->query->load($reference, false); |
| 68 | | $field = $map['table']->getColumnName($field); |
| 69 | | $func = $this->query->getTableAlias($reference) . '.' . $field; |
| 70 | | } else { |
| 71 | | $field = end($a); |
| 72 | | $func = $this->query->getAggregateAlias($field); |
| 73 | | } |
| 74 | | return $this->query->getConnection()->quoteIdentifier($func); |
| 75 | | } else { |
| 76 | | return $this->query->getConnection()->quoteIdentifier($func); |
| 77 | | } |
| | 61 | return $this->_parseAliases($func); |
| | 65 | /** |
| | 66 | * _parseAliases |
| | 67 | * Processes part of the query not being an aggregate function |
| | 68 | * |
| | 69 | * @param mixed $value |
| | 70 | * @return string |
| | 71 | */ |
| | 72 | final private function _parseAliases($value) |
| | 73 | { |
| | 74 | if ( ! is_numeric($value)) { |
| | 75 | $a = explode('.', $value); |
| | 76 | |
| | 77 | if (count($a) > 1) { |
| | 78 | $field = array_pop($a); |
| | 79 | $ref = implode('.', $a); |
| | 80 | $map = $this->query->load($ref, false); |
| | 81 | $field = $map['table']->getColumnName($field); |
| | 82 | $value = $this->query->getTableAlias($ref) . '.' . $field; |
| | 83 | } else { |
| | 84 | $field = end($a); |
| | 85 | $value = $this->query->getAggregateAlias($field); |
| | 86 | } |
| | 87 | |
| | 88 | return $this->query->getConnection()->quoteIdentifier($value); |
| | 89 | } |
| | 90 | |
| | 91 | |
| | 92 | return $value; |
| | 93 | } |