From f8e060eb9599d93d403c9ac36452cea012d91078 Mon Sep 17 00:00:00 2001 From: Andrii Dembitskyi Date: Wed, 27 Jan 2021 23:49:59 +0200 Subject: [PATCH] Introduce `fetch*` methods in query builder Fixes #4461 --- lib/Doctrine/DBAL/Query/QueryBuilder.php | 80 ++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/lib/Doctrine/DBAL/Query/QueryBuilder.php b/lib/Doctrine/DBAL/Query/QueryBuilder.php index 5ba7fea12d7..73791712cbe 100644 --- a/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -197,6 +197,86 @@ public function getState() return $this->state; } + /** + * @return array|false False is returned if no rows are found. + * + * @throws Exception + */ + public function fetchAssociative() + { + return $this->connection->fetchAssociative($this->getSQL(), $this->params, $this->paramTypes); + } + + /** + * @return array|false False is returned if no rows are found. + * + * @throws Exception + */ + public function fetchNumeric() + { + return $this->connection->fetchNumeric($this->getSQL(), $this->params, $this->paramTypes); + } + + /** + * @return mixed|false False is returned if no rows are found. + * + * @throws Exception + */ + public function fetchOne() + { + return $this->connection->fetchOne($this->getSQL(), $this->params, $this->paramTypes); + } + + /** + * @return array> + * + * @throws Exception + */ + public function fetchAllNumeric(): array + { + return $this->connection->fetchAllNumeric($this->getSQL(), $this->params, $this->paramTypes); + } + + /** + * @return array> + * + * @throws Exception + */ + public function fetchAllAssociative(): array + { + return $this->connection->fetchAllAssociative($this->getSQL(), $this->params, $this->paramTypes); + } + + /** + * @return array + * + * @throws Exception + */ + public function fetchAllKeyValue(): array + { + return $this->connection->fetchAllKeyValue($this->getSQL(), $this->params, $this->paramTypes); + } + + /** + * @return array> + * + * @throws Exception + */ + public function fetchAllAssociativeIndexed(): array + { + return $this->connection->fetchAllAssociativeIndexed($this->getSQL(), $this->params, $this->paramTypes); + } + + /** + * @return array + * + * @throws Exception + */ + public function fetchFirstColumn(): array + { + return $this->connection->fetchFirstColumn($this->getSQL(), $this->params, $this->paramTypes); + } + /** * Executes this query using the bound parameters and their types. *