当前位置: 首页>>代码示例>>PHP>>正文


PHP Banner::count方法代码示例

本文整理汇总了PHP中Banner::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Banner::count方法的具体用法?PHP Banner::count怎么用?PHP Banner::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Banner的用法示例。


在下文中一共展示了Banner::count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: listBanner

 public function listBanner()
 {
     if (!Request::ajax()) {
         return App::abort(404);
     }
     $start = Input::has('start') ? (int) Input::get('start') : 0;
     $length = Input::has('length') ? Input::get('length') : 10;
     $search = Input::has('search') ? Input::get('search') : [];
     $banners = Banner::select('id', 'name', 'order_no', 'image', 'active');
     if (!empty($search)) {
         foreach ($search as $key => $value) {
             if (empty($value)) {
                 continue;
             }
             if ($key == 'active') {
                 if ($value == 'yes') {
                     $value = 1;
                 } else {
                     $value = 0;
                 }
                 $banners->where($key, $value);
             } else {
                 $value = ltrim(rtrim($value));
                 $banners->where($key, 'like', '%' . $value . '%');
             }
         }
     }
     $order = Input::has('order') ? Input::get('order') : [];
     if (!empty($order)) {
         $columns = Input::has('columns') ? Input::get('columns') : [];
         foreach ($order as $value) {
             $column = $value['column'];
             if (!isset($columns[$column]['name']) || empty($columns[$column]['name'])) {
                 continue;
             }
             $banners->orderBy($columns[$column]['name'], $value['dir'] == 'asc' ? 'asc' : 'desc');
         }
     }
     $count = $banners->count();
     if ($length > 0) {
         $banners = $banners->skip($start)->take($length);
     }
     $arrBanners = $banners->get()->toArray();
     $arrReturn = ['draw' => Input::has('draw') ? Input::get('draw') : 1, 'recordsTotal' => Banner::count(), 'recordsFiltered' => $count, 'data' => []];
     if (!empty($arrBanners)) {
         foreach ($arrBanners as $banner) {
             $arrReturn['data'][] = array(++$start, $banner['id'], $banner['name'], $banner['image'], $banner['order_no'], $banner['active']);
         }
     }
     $response = Response::json($arrReturn);
     $response->header('Content-Type', 'application/json');
     return $response;
 }
开发者ID:nguyendaivu,项目名称:imagestock,代码行数:53,代码来源:BannersController.php

示例2: sort

 public function sort($id, $sort)
 {
     if (!in_array($sort, array('up', 'down'))) {
         return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '排序失敗!'));
     }
     $total = Banner::count();
     switch ($sort) {
         case 'up':
             $sort = $this->banner->sort;
             $this->banner->sort = $this->banner->sort + 1 >= $total ? 0 : $this->banner->sort + 1;
             break;
         case 'down':
             $sort = $this->banner->sort;
             $this->banner->sort = $this->banner->sort - 1 < 0 ? $total - 1 : $this->banner->sort - 1;
             break;
     }
     Banner::addConditions($conditions, 'sort = ?', $this->banner->sort);
     $banner = $this->banner;
     $update = Banner::transaction(function () use($conditions, $banner, $sort) {
         if (($next = Banner::find('one', array('conditions' => $conditions))) && (($next->sort = $sort) || true)) {
             if (!$next->save()) {
                 return false;
             }
         }
         if (!$banner->save()) {
             return false;
         }
         return true;
     });
     if (!$update) {
         return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '排序失敗!', 'posts' => $posts));
     }
     return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '排序成功!'));
 }
开发者ID:comdan66,项目名称:zeusdesign,代码行数:34,代码来源:banners.php

示例3: actionIndex

 /**
  * 首页
  *
  */
 public function actionIndex()
 {
     parent::_acl('banner_index');
     $model = new Banner();
     $criteria = new CDbCriteria();
     $criteria->order = 'id DESC';
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 5;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }
开发者ID:zywh,项目名称:maplecity,代码行数:18,代码来源:BannerController.php


注:本文中的Banner::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。