summaryrefslogtreecommitdiffstats
path: root/models/Kdrama.php
diff options
context:
space:
mode:
Diffstat (limited to 'models/Kdrama.php')
-rw-r--r--models/Kdrama.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/models/Kdrama.php b/models/Kdrama.php
new file mode 100644
index 0000000..9d3ddf7
--- /dev/null
+++ b/models/Kdrama.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace app\models;
+
+class Kdrama extends \lithium\data\Model {
+ protected $_meta = array('key' => '_id', 'source' => 'kdrama');
+
+ public static function search($query, $page = 1, $by = 'title')
+ {
+ $defaults = array('limit' => 20);
+ $limit = 20;
+
+ switch($by) {
+ case 'special_id':
+
+ $content = parent::find('first',
+ array('conditions' => array(
+ $by => $query
+ ),
+ 'limit' => $limit,
+ 'page' => $page
+ ));
+
+
+
+ $total = parent::count(array($by => $query));
+ break;
+
+ default:
+ $content = parent::find('all',
+ array('conditions' => array(
+ $by => array('like' => $query)
+ ),
+ 'limit' => $limit,
+ 'page' => $page
+ ));
+ $total = parent::count(array($by => array('like' => $query)));
+ }
+ return compact('content', 'by', 'limit', 'total', 'page');
+ }
+} \ No newline at end of file