|
|
@@ -7,21 +7,35 @@ class Anime extends \lithium\data\Model {
|
|
|
|
|
|
public static function search($query, $page = 1, $by = 'title')
|
|
|
{
|
|
|
- $defaults = array(
|
|
|
- 'limit' => 20
|
|
|
- );
|
|
|
+ $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');
|
|
|
+ switch($by) {
|
|
|
+ case 'special_id':
|
|
|
+
|
|
|
+ $content = self::find('first',
|
|
|
+ array('conditions' => array(
|
|
|
+ $by => $query
|
|
|
+ ),
|
|
|
+ 'limit' => $limit,
|
|
|
+ 'page' => $page
|
|
|
+ ));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $total = Anime::count(array($by => $query));
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ $content = self::find('all',
|
|
|
+ array('conditions' => array(
|
|
|
+ $by => array('like' => $query)
|
|
|
+ ),
|
|
|
+ 'limit' => $limit,
|
|
|
+ 'page' => $page
|
|
|
+ ));
|
|
|
+ $total = Anime::count(array($by => array('like' => $query)));
|
|
|
+ }
|
|
|
+ return compact('content', 'by', 'limit', 'total', 'page');
|
|
|
}
|
|
|
}
|