private function loadModel($id) { $model = Structure::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; }
/** * 创建Models中的数据库操作对象 * @param string $className 类名或表名 * @param string $app 应用名,访问其他应用的Model * @return object 数据库连接对象 */ function D($className = null, $app = "") { $db = null; //如果没有传表名或类名,则直接创建DB对象,但不能对表进行操作 if (is_null($className)) { $class = "D" . DRIVER; $db = new $class(); } else { $className = strtolower($className); $model = Structure::model($className, $app); $model = new $model(); //如果表结构不存在,则获取表结构 $model->setTable($className); $db = $model; } if ($app == "") { $db->path = APP_PATH; } else { $db->path = PROJECT_PATH . strtolower($app) . '/'; } return $db; }
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, )); }
<div><img class="border-banner" src="<?php echo Yii::app()->request->baseUrl; ?> /images/front/structure-banner.jpg"/></div> <h3><?php echo $header; ?> </h3> <?php foreach ($model as $type) { $str_type_id = $type->str_type_id; $Criteria = new CDbCriteria(); $Criteria->condition = 'status = 1 AND str_type_id =' . $str_type_id; $Criteria->order = 'sort_order'; $str_model = Structure::model()->findAll($Criteria); if (count($str_model) == 0) { continue; } ?> <div style="padding:10px 5px 5px 50px;background: #F1F1F1;"> <?php foreach ($str_model as $board) { if ($lang == 'en' || $lang == 'EN' || $lang == 'En') { $board_name = $board->name_en; $board_position = $board->position_en; $type = $type->name_en; } else { $board_name = $board->name_th; $board_position = $board->position_th;
public function actionIndex() { //查询最新的四张首页缩略图 $focusimgs = $this->getPictureFormImg(1,4); //一张竖幅广告(在热门商品下面) $shufuad = $this->getPictureFormImg(12,1); //查询最新的三张广告图片 $adsimg = $this->getPictureFormImg(2,3); //分配新闻内容到页面 /* $news = $this->getLastestNews(7); */ //分配 15条热门产品 (即点击量最靠前的15条产品) $tenhots = Travel::model()->findAll(array( 'select'=>'id,title,current_audlt_price', 'condition'=>'enabled=1', 'order'=>'views desc', 'limit'=>15, )); //分配16条更新时间 updatetime最新的产品信息 $sixteen = Travel::model()->findAll(array( 'select'=>'id,title', 'condition'=>'enabled=1', 'order'=>'updatetime desc', 'limit'=>16, )); //输出三个推广产品,首页底部的是三个推荐 $extendProduct = Travel::model()->findAll(array( 'select'=>'id,title,daynumber,current_audlt_price', 'condition'=>'enabled=1 and flag=1', 'order'=>'sort desc', 'limit'=>3, )); //查询各个模块(查看是否有些内容要隐藏) 至于 哪个模块对于哪个模块 请查看数据库 $structureArr = Structure::model()->findAll(array('order'=>'id asc')); //查询英国团的名称(只查询六个放到首页,其它与更多显示在搜索页面) $englishChildType = $this->getChildType(1); //查询欧洲团的名称(只查询六个放到首页,其它与更多显示在搜索页面) $euroChildType = $this->getChildType(3); //获取私人定制信息 $proctesinfo = $this->getTypeInfo(26); //获取豪华游轮信息 $cruiseinfo = $this->getTypeInfo(4); //获取商务接待信息 $busessinfo = $this->getTypeInfo(27); //分配特色团到页面(这里的特色团是flag标记为 1 的产品信息) $teseTuan = Travel::model()->findAll(array( 'select'=>'id,title', 'condition'=>'flag=1 and enabled=1', 'order'=>'sort desc', 'limit'=>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 group by yp_traveltype.name limit 0,9 ")->queryAll(); //出发地点 $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(); //目的地 $departurenum = $this->getTravelMdid();//array() $this->render('index',array( 'focusimgs'=>$focusimgs, 'adsimg'=>$adsimg, /* 'news'=>$news, */ 'tenhots'=>$tenhots, 'sixteen'=>$sixteen, 'extendProduct'=>$extendProduct, 'structureArr'=>$structureArr, 'englishChildType'=>$englishChildType, 'euroChildType'=>$euroChildType, 'proctesinfo'=>$proctesinfo, 'cruiseinfo'=>$cruiseinfo, 'busessinfo'=>$busessinfo, 'teseTuan'=>$teseTuan, 'types'=>$types, 'departures'=>$departures, 'departurenum'=>$departurenum, 'shufuad'=>$shufuad, )); }
public function getAllStructure() { $Criteria = new CDbCriteria(); $Criteria->condition = 'status = 1'; $Criteria->order = 'sort_order'; $model = Structure::model()->findAll($Criteria); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionIndex() { /* //检查是否进行了第一步(即是否有选择路线) $sessionid = Yii::app()->session['sid'];//Yii::app()->session->sessionID; $tempModel = $this->checkSessionId($sessionid); if(!$tempModel){ $this->render('404',array('msg'=>'您还没选择参团路线,快去选择吧!')); exit; } */ $code = $this->checkKParm(); $orderModel = $this->getOrderByRandCode($code); //如果没有该订单,说明没有通过一步步预定,非法操作 if(!$orderModel){ $this->redirect('/tuan'); exit; } //检查是否有上一步的选择房间 $token = 'order'.$orderModel->id; $roomArr = $this->checkOrderRoomStep($token); //start : 判断是否附加项全部隐藏了,如果全部隐藏则自动跳到下一步 //判断是否隐藏 $struct = Structure::model()->findAll(array('select'=>'enabled','condition'=>'id=6 or id=7 or id=8','order'=>'id asc')); if(empty($struct)){ $this->redirect($this->createUrl('/submit',array('k'=>$code))); exit; } //end $tid = $orderModel->tid;//产品ID //获取参数 $aduit = $orderModel->aduit;//参团成人人数 $child = $orderModel->child;//参团儿童人数 //分配门票附加项 $tickets = TravelAdditional::model()->findAll(array( 'select'=>'id,name,price', 'condition'=>"tid=$tid", )); //如果没有门票项目,则在视图中隐藏门票信息,这里设一个标志符 $flag = empty($tickets)?false:true; //获取价格 $Travelprice = $this->getTravelInfo($tid); $Travelprice->aduit_price = ($orderModel->aduit_price)*$aduit; $Travelprice->childen_price = ($orderModel->chilend_price)*$child; //房间价格 $housePriceTotal = $this->getRoomsPrice($token,$aduit,$child); //计算这部总价格 $nowTotalPrice = ($Travelprice->aduit_price) + ($Travelprice->childen_price) + $housePriceTotal; //获取保险项目 $insurance = Insurance::model()->findAll(array( 'select'=>'id,name,price,description', 'condition'=>"tid=$tid", )); $this->render('index',array( 'tickets'=>$tickets, 'flag'=>$flag, 'aduit'=>$aduit, 'child'=>$child, 'roomArr'=>$roomArr, 'Travelprice'=>$Travelprice, 'insurance'=>$insurance, 'housePriceTotal'=>$housePriceTotal, 'nowTotalPrice'=>$nowTotalPrice, 'token'=>$token, 'code'=>$code, 'struct'=>$struct, 'daynumber'=>$orderModel->daynumber, )); }