diff options
author | Michael Francis <edude03@gmail.com> | 2011-05-29 16:36:11 -0400 |
---|---|---|
committer | Michael Francis <edude03@gmail.com> | 2011-05-29 16:36:11 -0400 |
commit | b1629b5d2fbe13717fcf32fc83f40ea2e85f572f (patch) | |
tree | 459737f27e8afcc25d89422d19a80c77e2b88023 /models/Anime.php | |
parent | 3f7353eb51c90ce94081197f879637cb21da758a (diff) | |
download | otakuhub-b1629b5d2fbe13717fcf32fc83f40ea2e85f572f.tar.xz |
Moved search into the model
Diffstat (limited to 'models/Anime.php')
-rw-r--r-- | models/Anime.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/models/Anime.php b/models/Anime.php index ffa40eb..0877619 100644 --- a/models/Anime.php +++ b/models/Anime.php @@ -5,4 +5,23 @@ namespace app\models; class Anime extends \lithium\data\Model { protected $_meta = array('key' => '_id', 'source' => 'anime'); + public static function search($query, $page = 1, $by = 'title') + { + $defaults = array( + 'limit' => 20 + ); + + $limit = 20; + + $content = self::find('all', + array( + 'conditions' => array( + $by => array('like' => $query) + ), + 'limit' => $limit, + 'page' => $page + )); + $total = Anime::count(array('title' => array('like' => $query))); + return compact('content', 'by', 'limit', 'total', 'page'); + } }
\ No newline at end of file |