Add new method to search tags and series. re #34

This commit is contained in:
Sébastien Lucas 2013-09-27 17:10:07 +02:00
parent 8390411a58
commit acea490e00
2 changed files with 36 additions and 0 deletions

View file

@ -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;
}
}

18
tag.php
View file

@ -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;
}
}