/** * Fetch many result * * @param string $fields * @return object[] */ public function fetch(...$fields) { if (!$fields) { $fields = array_keys($this->entity->fields) ?: ['*']; } list($sql, $values) = SQL::select($this->entity->name, $fields, $this->where, $this->sort, $this->limit); return $this->execute($sql, $values, function (\PDOStatement $statement) { return $this->entity->class ? $statement->fetchAll(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $this->entity->class) : $statement->fetchAll(\PDO::FETCH_OBJ); }); }