public function sum($field, $where = []) { $sql = "SELECT sum({$field}) FROM " . $this->getTable() . ' ' . $this->join; $where_v = array(); if (count($where)) { $w = $this->where($where); $sql .= " WHERE " . $w['where']; return $this->conn->fetchOne($sql, $w['values']); } return $this->conn->fetchOne($sql); }