openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

commit 35e473e24392db6b6604f42dbf1a95c08ecd0732
parent 3f34c306a25e359f554d9f57cebd46fe2e02af7c
Author: Jan Dankert <develop@jandankert.de>
Date:   Sat,  6 Mar 2021 22:11:06 +0100

Cleanup: PDODriver#fetchrow() now only needs 1 argument.

Diffstat:
Mmodules/database/Statement.class.php | 21+++++++--------------
Mmodules/database/driver/PDODriver.class.php | 16++++++----------
2 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/modules/database/Statement.class.php b/modules/database/Statement.class.php @@ -113,14 +113,12 @@ class Statement $none = ''; $result = $this->query(); - $row = $this->client->fetchRow( $this->stmt, $result,0 ); + $row = $this->client->fetchRow($this->stmt); if ( ! is_array($row) ) return $none; - - $keys = array_keys($row); - - return $row[ $keys[0] ]; + + return array_values($row)[0];; } @@ -133,7 +131,7 @@ class Statement { $result = $this->query(); - $row = $this->client->fetchRow( $this->stmt, $result,0 ); + $row = $this->client->fetchRow($this->stmt); if ( ! is_array($row) ) $row = array(); @@ -153,7 +151,7 @@ class Statement $i = 0; $col = array(); - while( $row = $this->client->fetchRow( $this->stmt, $result,$i++ ) ) + while( $row = $this->client->fetchRow($this->stmt) ) { if ( empty($row) ) break; @@ -180,7 +178,7 @@ class Statement $i = 0; - while( $row = $this->client->fetchRow( $this->stmt, $result,$i++ ) ) + while( $row = $this->client->fetchRow($this->stmt) ) { if ( empty($row) ) break; @@ -213,15 +211,10 @@ class Statement */ public function &getAll() { - $result = $this->query(); - $results = array(); - $i = 0; - while( $row = $this->client->fetchRow( $this->stmt, $result,$i++ ) ) - { + while( $row = $this->client->fetchRow($this->stmt) ) $results[] = $row; - } return $results; } diff --git a/modules/database/driver/PDODriver.class.php b/modules/database/driver/PDODriver.class.php @@ -178,17 +178,13 @@ class PDODriver } - /** - * @param $stmt PDOStatement - * @param $result - * @param $rownum - * @return mixed Row - */ - public function fetchRow( $stmt, $result, $rownum ) + /** + * @param $stmt PDOStatement + * @return mixed Row + */ + public function fetchRow($stmt) { - $row = $stmt->fetch( PDO::FETCH_ASSOC ); - - return $row; + return $stmt->fetch( PDO::FETCH_ASSOC ); }