public function actionIndex() { //分配焦点图到页面 $focusmap = $this->getPictureFormImg(3,3); //分配5个旅游信息到页面 并分页显示 $travelsM = new Travel; $criteria=new CDbCriteria; $criteria->select = "id,title,to_addr,daynumber,thumb,current_audlt_price"; $criteria->condition = "enabled=1"; $criteria->order = "updatetime desc"; $criteria->compare('id',$travelsM->id,false,'or'); $count=$travelsM->count($criteria); $pages=new CPagination($count); $pages->pageSize=5; $pages->applyLimit($criteria); $travels = $travelsM->findAll($criteria); //end pagination //分配特色团到页面(这里的特色团是flag标记为 1 的产品信息) $teseTuan = $travelsM->findAll(array( 'select'=>'id,title,current_audlt_price', 'condition'=>'flag=1 and enabled=1', 'order'=>'sort desc', 'limit'=>15, )); //分配15个排序最靠前的旅游产品 作为 热门路线 $hottravels = $travelsM->findAll(array( 'select'=>'id,title', 'condition'=>'enabled=1', 'order'=>'sort desc', 'limit'=>15, )); //分配新闻内容到页面 $news = $this->getLastestNews(7); //分配旅游类型 $types = Yii::app()->db->createCommand("select yp_travel.type as id,yp_traveltype.name as name,count(yp_traveltype.name) as total from yp_travel,yp_traveltype where yp_travel.type=yp_traveltype.id and yp_travel.enabled<>0 group by yp_traveltype.name")->queryAll(); //分配旅游 出发地 $departurenum = $this->getTravelMdid();//array() $departurename = $this->getDepartureList();//array() $departures = Yii::app()->db->createCommand("select yp_departure.id as id, yp_departure.name as name,count(yp_travel.from_addr) as total from yp_travel,yp_departure where yp_travel.from_addr=yp_departure.id and yp_travel.enabled<>0 group by yp_travel.from_addr")->queryAll(); //旅游目的地 //$dests = Yii::app()->db->createCommand("select yp_travel.to_addr as name,count(yp_travel.to_addr) as total from yp_travel,yp_destination where yp_travel.to_addr=yp_destination.name group by yp_travel.to_addr")->queryAll(); //隐藏页面内容 $struct = Structure::model()->find(array('select'=>'enabled','condition'=>'id=9')); $this->render('index',array( 'focusmap'=>$focusmap, 'travels'=>$travels, 'news'=>$news, 'hottravels'=>$hottravels, 'types'=>$types, 'teseTuan'=>$teseTuan, 'departures'=>$departures, 'departurenum'=>$departurenum, 'departurename'=>$departurename, 'pages'=>$pages, 'struct'=>$struct, )); }