/** * Fetch many result * * @param string $fields * @return object[] */ public function fetch(...$fields) { $fields = $fields ?: ['*']; list($sql, $values) = $this->compiler->select($this->name, $fields, $this->where, $this->sort, $this->limit); // prepare statement & execute if ($statement = $this->pdo->prepare($sql) and $result = $statement->execute($values)) { return $this->class ? $statement->fetchAll(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $this->class) : $statement->fetchAll(\PDO::FETCH_OBJ); } // error $error = $this->pdo->errorInfo(); throw new \PDOException('[' . $error[0] . '] ' . $error[2], $error[0]); }