summaryrefslogtreecommitdiffstats
path: root/models/Manga.php
diff options
context:
space:
mode:
authorMichael Francis <edude03@gmail.com>2011-07-17 20:38:31 -0400
committerMichael Francis <edude03@gmail.com>2011-07-17 20:38:31 -0400
commitc9994190d2ba584e1eb95b6b47ff586da7b0f29f (patch)
treeff4d02327f8e988925036f7406c760dfba8791d3 /models/Manga.php
parent7be960630a8c0b4dab94245c73453b22db3f305e (diff)
parent2baaf56e140a06eed8fe0b1d28d744d34a537d49 (diff)
downloadotakuhub-c9994190d2ba584e1eb95b6b47ff586da7b0f29f.tar.xz
Merge branch 'master' of git.raylu.net:otakuhub
Diffstat (limited to 'models/Manga.php')
-rw-r--r--models/Manga.php34
1 files changed, 32 insertions, 2 deletions
diff --git a/models/Manga.php b/models/Manga.php
index 03c2d29..5f79bef 100644
--- a/models/Manga.php
+++ b/models/Manga.php
@@ -5,5 +5,35 @@ namespace app\models;
class Manga extends \lithium\data\Model {
protected $_meta = array('key' => '_id', 'source' => 'manga', 'connection' => 'mongo');
-
-} \ No newline at end of file
+ public static function search($query, $page = 1, $by = 'title')
+ {
+ $defaults = array('limit' => 20);
+ $limit = 20;
+
+ switch($by) {
+ case 'special_id':
+
+ $manga = parent::find('first',
+ array('conditions' => array(
+ $by => $query
+ ),
+ 'limit' => $limit,
+ 'page' => $page
+ ));
+
+ $total = parent::count(array($by => $query));
+ break;
+
+ default:
+ $manga = parent::find('all',
+ array('conditions' => array(
+ $by => array('like' => $query)
+ ),
+ 'limit' => $limit,
+ 'page' => $page
+ ));
+ $total = parent::count(array($by => array('like' => $query)));
+ }
+ return compact('manga', 'by', 'limit', 'total', 'page');
+ }
+}