| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- 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;
- switch($by) {
- case 'special_id':
-
- $content = self::find('first',
- array('conditions' => array(
- $by => $query
- ),
- 'limit' => $limit,
- 'page' => $page
- ));
-
- $total = self::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');
- }
- }
|