From 8389c2a2d6f9d8085f5dabdbcb588248e58898f0 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 5 Nov 2022 08:46:42 +0100 Subject: [PATCH] minor optimization, let the PDO driver do that for us --- lib/Data/Database.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/Data/Database.php b/lib/Data/Database.php index 3771b5d..e067899 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -486,19 +486,13 @@ class Database extends AbstractData */ protected function _getExpiredPastes($batchsize) { - $pastes = array(); - $rows = $this->_select( + $statement = $this->_db->prepare( 'SELECT "dataid" FROM "' . $this->_sanitizeIdentifier('paste') . '" WHERE "expiredate" < ? AND "expiredate" != ? ' . - ($this->_type === 'oci' ? 'FETCH NEXT ? ROWS ONLY' : 'LIMIT ?'), - array(time(), 0, $batchsize) + ($this->_type === 'oci' ? 'FETCH NEXT ? ROWS ONLY' : 'LIMIT ?') ); - if (is_array($rows) && count($rows)) { - foreach ($rows as $row) { - $pastes[] = $row['dataid']; - } - } - return $pastes; + $statement->execute(array(time(), 0, $batchsize)); + return $statement->fetchAll(PDO::FETCH_COLUMN, 0); } /** @@ -506,10 +500,9 @@ class Database extends AbstractData */ public function getAllPastes() { - $pastes = $this->_db->_query( + return $this->_db->_query( 'SELECT "dataid" FROM "' . $this->_sanitizeIdentifier('paste') . '"' )->fetchAll(PDO::FETCH_COLUMN, 0); - return $pastes; } /**