Example #1
0
 /**
  * 首页
  */
 public function actionIndex()
 {
     $bagecmsQuestionModel = new Question();
     $bagecmsQuestionCriteria = new CDbCriteria();
     $bagecmsQuestionCriteria->condition = 'status_is=:status';
     $bagecmsQuestionCriteria->params = array('status' => 'Y');
     $bagecmsQuestionCriteria->order = 't.id DESC';
     $bagecmsQuestionCount = $bagecmsQuestionModel->count($bagecmsQuestionCriteria);
     $bagecmsQuestionPages = new CPagination($bagecmsQuestionCount);
     $bagecmsQuestionPages->pageSize = 10;
     $bagecmsQuestionPageParams = XUtils::buildCondition($_GET, array());
     $bagecmsQuestionPageParams['#'] = 'list';
     $bagecmsQuestionPages->params = is_array($bagecmsQuestionPageParams) ? $bagecmsQuestionPageParams : array();
     $bagecmsQuestionCriteria->limit = $bagecmsQuestionPages->pageSize;
     $bagecmsQuestionCriteria->offset = $bagecmsQuestionPages->currentPage * $bagecmsQuestionPages->pageSize;
     $bagecmsQuestionList = $bagecmsQuestionModel->findAll($bagecmsQuestionCriteria);
     $this->_seoTitle = '留言咨询 - ' . $this->_conf['site_name'];
     $this->render('index', array('bagecmsQuestionList' => $bagecmsQuestionList, 'pages' => $bagecmsQuestionPages));
 }
Example #2
0
 public function run()
 {
     $model = new Question();
     //条件
     $criteria = new CDbCriteria();
     $realname = trim(Yii::app()->request->getParam('realname'));
     $question = trim(Yii::app()->request->getParam('question'));
     $question && $criteria->addSearchCondition('question', $question);
     $realname && $criteria->addSearchCondition('realname', $realname);
     $criteria->order = 't.id ASC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     $this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages));
 }
Example #3
0
 /**
  * 首页
  */
 public function actionIndex()
 {
     $model = new Question();
     $criteria = new CDbCriteria();
     $condition = '1';
     $realname = trim($this->_request->getParam('realname'));
     $question = trim($this->_request->getParam('question'));
     $question && ($condition .= ' AND question LIKE \'%' . $question . '%\'');
     $realname && ($condition .= ' AND realname LIKE \'%' . $realname . '%\'');
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 15;
     $pageParams = $this->buildCondition($_GET, array('site_name'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }