From cb26b19d26d489e40fa381ccee17e7466fc8428b Mon Sep 17 00:00:00 2001 From: Karel Wintersky Date: Thu, 12 Sep 2024 13:59:09 +0300 Subject: [PATCH] 1.99.1 - PHP 7.4 & 8.* version - fix PHP8 bugs --- src/Queries/Base.php | 3 ++- src/Queries/Select.php | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Queries/Base.php b/src/Queries/Base.php index 36d911c..334a207 100644 --- a/src/Queries/Base.php +++ b/src/Queries/Base.php @@ -196,6 +196,7 @@ protected function resetClause($clause) * * @throws Exception */ + #[\ReturnTypeWillChange] public function getIterator() { return $this->execute(); @@ -204,7 +205,7 @@ public function getIterator() /** * Execute query with earlier added parameters * - * @return \PDOStatement + * @return \PDOStatement|null * * @throws Exception */ diff --git a/src/Queries/Select.php b/src/Queries/Select.php index 3652ca8..5cfd1b5 100644 --- a/src/Queries/Select.php +++ b/src/Queries/Select.php @@ -127,8 +127,12 @@ public function fetch(?string $column = null, int $cursorOrientation = \PDO::FET if ($this->result === false) { return false; } - - $row = $this->result->fetch( $this->currentFetchMode, $cursorOrientation ); + + if (is_null($this->currentFetchMode)) { + $row = $this->result->fetch( \PDO::FETCH_ASSOC, $cursorOrientation ); + } else { + $row = $this->result->fetch( $this->currentFetchMode, $cursorOrientation ); + } if ($this->fluent->convertRead === true) { $row = Utilities::stringToNumeric( $this->result, $row ); @@ -183,7 +187,7 @@ public function fetchAll($index = '', $selectOnly = '') } if ($selectOnly) { - $this->select( $index.', '.$selectOnly, true ); + $this->select( $index . ', ' . $selectOnly, true ); } if ($index) { @@ -208,7 +212,8 @@ public function fetchAll($index = '', $selectOnly = '') * @throws Exception * */ - public function count() + #[\ReturnTypeWillChange] + public function count(): int { $fluent = clone $this; @@ -220,6 +225,7 @@ public function count() * @throws Exception * */ + #[\ReturnTypeWillChange] public function getIterator() { if ($this->fluent->convertRead === true) { @@ -235,7 +241,7 @@ public function getIterator() * * @return array */ - private function buildSelectData($index, $indexAsArray) + private function buildSelectData($index, $indexAsArray): array { $data = [];