if (strpos($select, ','
) !== false
) { throw DataException::
forInvalidArgument('column name not separated by comma'
);
} $type =
strtoupper($type);
if (!
in_array($type,
['MAX', 'MIN', 'AVG', 'SUM', 'COUNT'
], true
)) { throw new DatabaseException('Invalid function type: ' .
$type);
} if ($alias === ''
) { $alias =
$this->
createAliasFromTable(trim($select));
} $sql =
$type . '(' .
$this->db->
protectIdentifiers(trim($select)) . ') AS ' .
$this->db->
escapeIdentifiers(trim($alias));
$this->QBSelect
[] =
$sql;
$this->QBNoEscape
[] = null;
return $this;
} /**
* Determines the alias name based on the table
*/