public function action_grid() { $userName = Input::post('username'); if (empty($userName)) { $userName = "******"; } else { $userName = "******" . $userName . "%"; } $email = Input::post('email'); if (empty($email)) { $email = "%%"; } else { $email = "%" . $email . "%"; } $limit = (int) Input::post('limit'); $page = (int) Input::post('page'); $limit = isset($limit) ? $limit : $this->_paginationConfig['limit_default']; $page = isset($page) ? $page : 1; $result = DB::select(DB::expr('COUNT(id) as total'))->from('users')->where('username', 'like', $userName)->where('email', 'like', $email)->execute()->as_array(); $total = $result[0]['total']; $pagination = Model_Paginator::getPaginationData($page, $limit, $total, $this->_paginationConfig); $data['pagination'] = $pagination; $data['users'] = DB::select()->from('users')->where('username', 'like', $userName)->where('email', 'like', $email)->order_by("created_at", "desc")->limit($pagination->limit)->offset($pagination->offset)->as_object()->execute(); $this->template = View::forge('admin/users/grid', $data, false); }
public function action_grid() { $title = Input::post('title'); if (empty($title)) { $title = "%%"; } else { $title = "%" . $title . "%"; } $summary = Input::post('summary'); if (empty($summary)) { $summary = "%%"; } else { $summary = "%" . $summary . "%"; } $date = Input::post('date'); if (empty($date)) { $date = "%%"; } else { $date = "%" . $date . "%"; } $limit = (int) Input::post('limit'); $page = (int) Input::post('page'); $limit = isset($limit) ? $limit : $this->_paginationConfig['limit_default']; $page = isset($page) ? $page : 1; $result = DB::select(DB::expr('COUNT(id) as total'))->from('dates')->where('title', 'like', $title)->where('summary', 'like', $summary)->execute()->as_array(); $total = $result[0]['total']; $pagination = Model_Paginator::getPaginationData($page, $limit, $total, $this->_paginationConfig); $data['pagination'] = $pagination; $data['dates'] = DB::select()->from('dates')->where('title', 'like', $title)->where('summary', 'like', $summary)->order_by("created_at", "desc")->limit($pagination->limit)->offset($pagination->offset)->as_object()->execute(); $this->template = View::forge('admin/date/grid', $data, false); }
public function action_grid() { $name = Input::post('name'); if (empty($name)) { $name = "%%"; } else { $name = "%" . $name . "%"; } $category = Input::post('category'); if (empty($category)) { $operator = "!="; $category = ""; } else { $operator = "="; $category = $category; } $writter = Input::post('writter'); if (empty($writter)) { $writterOperator = "!="; $writter = ""; } else { $writterOperator = "="; $writter = $writter; } $status = Input::post('status'); if (empty($status)) { $statusOperator = "!="; $status = ""; } else { $statusOperator = "="; $status = $status; } $deleted = Input::post('deleted'); if (empty($deleted)) { $deletedOperator = "="; $deleted = 0; } else { $deletedOperator = "="; $deleted = $deleted; } $completion = Input::post('completion'); if (empty($completion)) { $completionOperator = "!="; $completion = ""; } else { $completionOperator = "="; $completion = $completion; } $limit = (int) Input::post('limit'); $page = (int) Input::post('page'); $limit = isset($limit) ? $limit : $this->_paginationConfig['limit_default']; $page = isset($page) ? $page : 1; $result = DB::select(DB::expr('COUNT(id) as total'))->from('articles')->where('name', 'like', $name)->where('category_id', $operator, $category)->where('user_id', $writterOperator, $writter)->where('status', $statusOperator, $status)->where('deleted', $deletedOperator, $deleted)->where('completion', $completionOperator, $completion)->execute()->as_array(); $total = $result[0]['total']; $pagination = Model_Paginator::getPaginationData($page, $limit, $total, $this->_paginationConfig); $data['pagination'] = $pagination; $data['articles'] = DB::select()->from('articles')->where('name', 'like', $name)->where('category_id', $operator, $category)->where('user_id', $writterOperator, $writter)->where('status', $statusOperator, $status)->where('deleted', $deletedOperator, $deleted)->where('completion', $completionOperator, $completion)->order_by("created_at", "desc")->limit($pagination->limit)->offset($pagination->offset)->as_object()->execute(); //echo DB::last_query(); $this->template = View::forge('admin/article/grid', $data, false); }