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


PHP Base_Model::get_many_by方法代码示例

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


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

示例1: paginate

 public function paginate($page = 1, $where = array(), $limit = 10)
 {
     // get filtered results
     $where = array_merge($where, $this->where);
     $offset = $page <= 1 ? 0 : ($page - 1) * $limit;
     $this->db->limit($limit, $offset);
     $results = parent::get_many_by($where);
     // get counts (e.g. for pagination)
     $count_results = count($results);
     $count_total = parent::count_by($where);
     $total_pages = ceil($count_total / $limit);
     $counts = array('from_num' => $count_results == 0 ? 0 : $offset + 1, 'to_num' => $count_results == 0 ? 0 : $offset + $count_results, 'total_num' => $count_total, 'curr_page' => $page, 'total_pages' => $count_results == 0 ? 1 : $total_pages, 'limit' => $limit);
     return array('data' => $results, 'counts' => $counts);
 }
开发者ID:TowerX,项目名称:ci_bootstrap_3,代码行数:14,代码来源:MY_Model.php

示例2: paginate

 public function paginate($page = 1, $where = array(), $limit = NULL)
 {
     // decide per-page limit by: 1) $this->limit; 2) a default value (10)
     if (!empty($this->limit) && $limit === NULL) {
         $limit = $this->limit;
     } else {
         if ($limit === NULL) {
             $limit = 10;
         }
     }
     // avoid overrided by $this->limit
     $this->limit = NULL;
     // get filtered results
     $where = array_merge($where, $this->where);
     $offset = $page <= 1 ? 0 : ($page - 1) * $limit;
     $this->db->limit($limit, $offset);
     $results = parent::get_many_by($where);
     // get counts (e.g. for pagination)
     $count_results = count($results);
     $count_total = parent::count_by($where);
     $total_pages = ceil($count_total / $limit);
     $counts = array('from_num' => $count_results == 0 ? 0 : $offset + 1, 'to_num' => $count_results == 0 ? 0 : $offset + $count_results, 'total_num' => $count_total, 'curr_page' => $page, 'total_pages' => $count_results == 0 ? 1 : $total_pages, 'limit' => $limit);
     return array('data' => $results, 'counts' => $counts);
 }
开发者ID:jothamhernandez,项目名称:PT_HIFI,代码行数:24,代码来源:MY_Model.php


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