Exemplo n.º 1
0
 public function actionSearch()
 {
     $keyword = trim($_GET['q']);
     if (isset($keyword)) {
         $condition = new CDbCriteria();
         $condition->condition = "name_th LIKE '%{$keyword}%' OR name_en LIKE '%{$keyword}%' OR desc_th LIKE '%{$keyword}%' OR desc_en LIKE '%{$keyword}%'";
         $condition->order = "create_date desc";
         $condition->offset = 0;
         $condition->limit = 20;
         $model_news = News::model()->findAll($condition);
         $condition = new CDbCriteria();
         $condition->condition = "name_th LIKE '%{$keyword}%' OR name_en LIKE '%{$keyword}%'";
         $condition->order = "last_update desc";
         $condition->offset = 0;
         $condition->limit = 20;
         $model_document = Document::model()->findAll($condition);
         $condition = new CDbCriteria();
         $condition->condition = "name_th LIKE '%{$keyword}%' OR name_en LIKE '%{$keyword}%'";
         $condition->order = "know_id desc";
         $condition->offset = 0;
         $condition->limit = 20;
         $model_knowledge = Knowledge::model()->findAll($condition);
         $condition = new CDbCriteria();
         $condition->condition = "name_th LIKE '%{$keyword}%' OR name_en LIKE '%{$keyword}%' OR desc_th LIKE '%{$keyword}%' OR desc_en LIKE '%{$keyword}%'";
         $condition->order = "last_update desc";
         $condition->offset = 0;
         $condition->limit = 20;
         $model_student = StudentService::model()->findAll($condition);
         //print_r($model);
         $this->render('search', array('model_news' => $model_news, 'model_document' => $model_document, 'model_knowledge' => $model_knowledge, 'model_student' => $model_student));
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return StudentService the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = StudentService::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 3
0
 public function actionGroup3()
 {
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->condition = 'status = 1 AND ser_group=3';
     $criteria->order = 'sort_order';
     $total = StudentService::model()->count($criteria);
     $pages = new CPagination($total);
     $pages->setPageSize(20);
     $pages->applyLimit($criteria);
     $model = StudentService::model()->findAll($criteria);
     $this->render('index', array('model' => $model, 'pages' => $pages));
 }