/** * 首页 * */ public function actionIndex() { parent::_acl('city_index'); $model = new City(); $criteria = new CDbCriteria(); $criteria->order = 'id ASC'; $count = $model->count($criteria); $pages = new CPagination($count); $pages->pageSize = 10; $criteria->limit = $pages->pageSize; $criteria->offset = $pages->currentPage * $pages->pageSize; $result = $model->findAll($criteria); $this->render('index', array('datalist' => $result, 'pagebar' => $pages)); }
public function actionAutoCompleteUrl($term) { if(isset($_GET['term'])) { $arr = array(); $criteria = new CDbCriteria(); $criteria->compare('LOWER(url)',MHelper::String()->toLower($_GET['term']),true); $criteria->limit = 50; $model = new City; foreach($model->findAll($criteria) as $m) { $arr[] = $m->url; } } echo CJSON::encode($arr); Yii::app()->end(); }