From ed240d53b0f12aa1af953b1d3a711984a9b6df78 Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 25 Jun 2023 23:29:30 +0300 Subject: [PATCH] show available snaps only --- library/mysql.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/mysql.php b/library/mysql.php index 3942ab7..f553433 100644 --- a/library/mysql.php +++ b/library/mysql.php @@ -406,20 +406,20 @@ class MySQL { return $query->rowCount(); } - public function getTotalHostPageSnaps(int $hostPageId) { + public function getTotalHostPageSnaps(int $hostPageId, bool $storageLocal = true, bool $storageMega = true) { - $query = $this->_db->prepare('SELECT COUNT(*) AS `total` FROM `hostPageSnap` WHERE `hostPageId` = ?'); + $query = $this->_db->prepare('SELECT COUNT(*) AS `total` FROM `hostPageSnap` WHERE `hostPageId` = ? AND (`storageLocal` = ? OR `storageMega` = ?)'); - $query->execute([$hostPageId]); + $query->execute([$hostPageId, $storageLocal, $storageMega]); return $query->fetch()->total; } - public function getHostPageSnaps(int $hostPageId) { + public function getHostPageSnaps(int $hostPageId, bool $storageLocal = true, bool $storageMega = true) { - $query = $this->_db->prepare('SELECT * FROM `hostPageSnap` WHERE `hostPageId` = ? ORDER BY `timeAdded` DESC'); + $query = $this->_db->prepare('SELECT * FROM `hostPageSnap` WHERE `hostPageId` = ? AND (`storageLocal` = ? OR `storageMega` = ?) ORDER BY `timeAdded` DESC'); - $query->execute([$hostPageId]); + $query->execute([$hostPageId, $storageLocal, $storageMega]); return $query->fetchAll(); }