public function sum($field, $name = null) { $func = "SUM(" . $field . ")" . (!is_null($name) ? " AS " . $name : ""); $this->select = $this->select == '*' ? $func : $this->select . ", " . $func; return $this; }