From acea490e00d35baf111860bf53fe12301a1556de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Fri, 27 Sep 2013 17:10:07 +0200 Subject: [PATCH] Add new method to search tags and series. re #34 --- serie.php | 18 ++++++++++++++++++ tag.php | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/serie.php b/serie.php index 9dac0f3..b377881 100644 --- a/serie.php +++ b/serie.php @@ -72,4 +72,22 @@ order by series.sort'); } return $entryArray; } + + public static function getAllSeriesByQuery($query) { + $result = parent::getDb ()->prepare('select series.id as id, series.name as name, series.sort as sort, count(*) as count +from series, books_series_link +where series.id = series and series.name like ? +group by series.id, series.name, series.sort +order by series.sort'); + $entryArray = array(); + $result->execute (array ('%' . $query . '%')); + while ($post = $result->fetchObject ()) + { + $serie = new Serie ($post->id, $post->sort); + array_push ($entryArray, new Entry ($serie->name, $serie->getEntryId (), + str_format (localize("bookword", $post->count), $post->count), "text", + array ( new LinkNavigation ($serie->getUri ())))); + } + return $entryArray; + } } diff --git a/tag.php b/tag.php index 3664b0d..b3d9a23 100644 --- a/tag.php +++ b/tag.php @@ -61,4 +61,22 @@ order by tags.name'); } return $entryArray; } + + public static function getAllTagsByQuery($query) { + $result = parent::getDb ()->prepare('select tags.id as id, tags.name as name, count(*) as count +from tags, books_tags_link +where tags.id = tag and tags.name like ? +group by tags.id, tags.name +order by tags.name'); + $entryArray = array(); + $result->execute (array ('%' . $query . '%')); + while ($post = $result->fetchObject ()) + { + $tag = new Tag ($post->id, $post->name); + array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (), + str_format (localize("bookword", $post->count), $post->count), "text", + array ( new LinkNavigation ($tag->getUri ())))); + } + return $entryArray; + } }