コード例 #1
0
ファイル: AppIndex.php プロジェクト: fu-tao/meelier_c2.0
 /**
  * 获取广告
  * @date: 2016年1月22日 
  * @author: 545
  */
 private function getAdvert($city_id, $where = null, $order = null, $groupby = null)
 {
     $where = empty($where) ? "city_id = {$city_id} " : $where . " AND city_id = {$city_id} ";
     if (!empty($groupby)) {
         $where .= " GROUP BY {$groupby}";
     }
     $advert = Advertisement::query()->columns(['advertisement_id', 'advertisement_cover', 'advertisement_title', 'position', 'type', 'advertisement_intro', 'out_link'])->where($where)->orderBy($order)->execute()->toArray();
     return $advert;
 }
コード例 #2
0
ファイル: OmController.php プロジェクト: fu-tao/meelier_c2.0
 /**
  * 广告位列表
  * @date: 2016年1月7日 
  * @author: chenxiaolin
  */
 public function advertisementListAction()
 {
     $this->setLeftNav('advertisementList');
     $req = $this->request;
     $page = intval($req->getQuery('page', null, 1));
     $page = $page > 0 ? $page : 1;
     $limit = $this->pageNavLimit;
     $offset = $limit * ($page - 1);
     $filterCity = $req->getQuery('filterCity', null, -10000);
     $title = $req->getQuery('advertisement_title');
     $where = [];
     if ($filterCity > -10000) {
         $where[] = "Apps\\Common\\Models\\Advertisement.city_id = {$filterCity}";
     }
     if ($title != '') {
         $where[] = "advertisement_title like '%" . $title . "%'";
         $this->view->setVar("advertisement_title", $title);
     }
     $whereStr = implode(' AND ', $where);
     $total = Advertisement::count($whereStr);
     $data = Advertisement::query()->columns(['advertisement_id', 'advertisement_cover', 'advertisement_title', 'position', 'addtime', 'Apps\\Common\\Models\\Advertisement.city_id', 'soc.city_name'])->leftJoin('Apps\\Common\\Models\\SysOpenCity', 'soc.city_id=Apps\\Common\\Models\\Advertisement.city_id', 'soc')->where($whereStr)->limit($limit, $offset)->orderBy('addtime DESC')->execute()->toArray();
     //处理广告封面
     foreach ($data as $k => $v) {
         $data[$k]['advertisement_cover'] = PicUrl::AdvertisementPic($data[$k]['advertisement_cover'], $this->getDi());
     }
     $this->view->setVar('data', $data);
     $this->view->setVar('total', $total);
     $this->view->setVar('page', $page);
     $this->view->setVar('limit', $limit);
     $this->view->setVar("filterCity", $filterCity);
     $this->view->setVar('openCity', $this->openCityList());
 }