From 4a1f06fd828a2c5eeda054f4c737734043387805 Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 26 Sep 2023 14:46:21 +0300 Subject: [PATCH] add text methods --- src/app/model/database.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/app/model/database.php b/src/app/model/database.php index a8582d0..9ecd87d 100644 --- a/src/app/model/database.php +++ b/src/app/model/database.php @@ -77,6 +77,40 @@ class AppModelDatabase return $this->_debug; } + // Text + public function addText(string $mime, string $hash, string $value) : int + { + $this->_debug->query->insert->total++; + + $query = $this->_db->prepare('INSERT INTO `text` SET `mime` = ?, `hash` = ?, `value` = ?'); + + $query->execute([$mime, $hash, $value]); + + return $this->_db->lastInsertId(); + } + + public function getText(int $textId) + { + $this->_debug->query->select->total++; + + $query = $this->_db->prepare('SELECT * FROM `text` WHERE `textId` = ?'); + + $query->execute([$textId]); + + return $query->fetch(); + } + + public function findText(string $mime, string $hash) + { + $this->_debug->query->select->total++; + + $query = $this->_db->prepare('SELECT * FROM `text` WHERE `mime` = ? AND `hash` = ?'); + + $query->execute([$mime, $hash]); + + return $query->fetch(); + } + // Page public function addPage(int $timeAdded) : int {