Skip to content
This repository was archived by the owner on Jun 27, 2021. It is now read-only.

Commit 257a669

Browse files
committed
fetch style changed for count
1 parent c8ad0fb commit 257a669

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/SQLQueryBuilder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ public function run()
1212
$this->queryBuilder = $this->getQueryBuilder();
1313
$this->setJoins();
1414
$count = $this->getCount();
15-
if (!isset($count[0]['total']) || ($count[0]['total']===0)) {
15+
if (!isset($count['total']) || ($count['total']==='0')) {
1616
return ['total' => 0, 'data' => null];
1717
}
18-
$numberOfRows = $count[0]['total'];
18+
$numberOfRows = (int) $count['total'];
1919
$this->setSortOrders();
2020
$this->setOffsetAndLimit();
2121
$this->setReturnFields();
@@ -44,7 +44,7 @@ private function getCount()
4444
$queryBuilderCount = clone $this->queryBuilder;
4545
$queryBuilderCount->select(' COUNT(*) AS total ');
4646
$stmt = $this->conn->executeQuery($queryBuilderCount->getSql(), $queryBuilderCount->getParameters());
47-
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
47+
return $stmt->fetch(\PDO::FETCH_ASSOC);
4848
}
4949

5050
private function setSortOrders()

0 commit comments

Comments
 (0)