setStatement($statement); } protected PDOStatement $statement; protected function getStatement(): PDOStatement { return $this->statement; } protected function setStatement(PDOStatement $statement): ResultSet { $this->statement = $statement; return $this; } public function execute(array $data): Database\ResultSet { $this->statement->execute($data); return $this; } protected function checkResults(): PDOStatement { if ($this->getStatement()->rowCount() === 0) { throw new BlankResult(query: $this->getStatement()->queryString); } return $this->getStatement(); } public function fetchFirst(): array { return $this->checkResults()->fetch(PDO::FETCH_ASSOC); } public function fetchAll(): array { return $this->checkResults()->fetchAll(PDO::FETCH_ASSOC); } public function fetchFirstAsObject(): object { return $this->checkResults()->fetch(PDO::FETCH_OBJ); } public function fetchAllAsObjects(): array { return $this->checkResults()->fetchAll(PDO::FETCH_OBJ); } }