Granada\ORM::_call_aggregate_db_function PHP Method

_call_aggregate_db_function() protected method

Execute an aggregate query on the current connection.
protected _call_aggregate_db_function ( string $sql_function, string $column ) : integer
$sql_function string The aggregate function to call eg. MIN, COUNT, etc
$column string The column to execute the aggregate query against
return integer
    protected function _call_aggregate_db_function($sql_function, $column)
    {
        $alias = strtolower($sql_function);
        $sql_function = strtoupper($sql_function);
        if ('*' != $column) {
            $column = $this->_quote_identifier($column);
        }
        $result_columns = $this->_result_columns;
        $this->_result_columns = array();
        $this->select_expr("{$sql_function}({$column})", $alias);
        $result = $this->find_one();
        $this->_result_columns = $result_columns;
        $return_value = 0;
        if ($result !== false && isset($result->{$alias})) {
            if (!is_numeric($result->{$alias})) {
                $return_value = $result->{$alias};
            } elseif ((int) $result->{$alias} == (double) $result->{$alias}) {
                $return_value = (int) $result->{$alias};
            } else {
                $return_value = (double) $result->{$alias};
            }
        }
        return $return_value;
    }
ORM