From 7d8cfd351e80bff9aae35aaa65c020176648ce48 Mon Sep 17 00:00:00 2001 From: Mike Colagrosso Date: Mon, 9 Sep 2024 22:34:36 -0600 Subject: [PATCH] Ebook tags: Store UrlName so it can be queried --- config/sql/se/Tags.sql | 4 +++- lib/EbookTag.php | 5 +++-- lib/Library.php | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config/sql/se/Tags.sql b/config/sql/se/Tags.sql index b817640d..81a478df 100644 --- a/config/sql/se/Tags.sql +++ b/config/sql/se/Tags.sql @@ -1,8 +1,10 @@ CREATE TABLE IF NOT EXISTS `Tags` ( `TagId` int(10) unsigned NOT NULL AUTO_INCREMENT, `Name` varchar(255) NOT NULL, + `UrlName` varchar(255) NULL, `Type` enum('artwork', 'ebook') DEFAULT 'artwork', PRIMARY KEY (`TagId`), KEY `index1` (`Name`), - KEY `index2` (`Type`) + KEY `index2` (`Type`), + KEY `index3` (`UrlName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/lib/EbookTag.php b/lib/EbookTag.php index e091a0ad..1263c448 100644 --- a/lib/EbookTag.php +++ b/lib/EbookTag.php @@ -53,10 +53,11 @@ class EbookTag extends Tag{ $this->Validate(); Db::Query(' - INSERT into Tags (Name, Type) + INSERT into Tags (Name, UrlName, Type) values (?, + ?, ?) - ', [$this->Name, $this->Type]); + ', [$this->Name, $this->UrlName, $this->Type]); $this->TagId = Db::GetLastInsertedId(); } diff --git a/lib/Library.php b/lib/Library.php index 5b293d3c..e1388363 100644 --- a/lib/Library.php +++ b/lib/Library.php @@ -40,7 +40,7 @@ class Library{ if(sizeof($tags) > 0 && !in_array('all', $tags)){ // 0 tags means "all ebooks" $joinTags = 'inner join EbookTags et using (EbookId) inner join Tags t using (TagId)'; - $whereCondition .= ' AND t.Name in ' . Db::CreateSetSql($tags) . ' '; + $whereCondition .= ' AND t.UrlName in ' . Db::CreateSetSql($tags) . ' '; $params = $tags; }