作者 jinglong
1 个管道 的构建 通过 耗费 6 秒

修改猜你喜欢数据分页

... ... @@ -211,12 +211,16 @@ class Common
* 查询总页数(软删除)
* @ApiInternal
*/
public static function countSoft($table,$where){
$limit = config('verify.limit');
$count = Db::name($table)
->where($where)
->useSoftDelete('deletetime')
->count();
public static function countSoft($table,$where='',$limit=''){
if(empty($limit)){
$limit = config('verify.limit');
}
if(empty($where)){
$count = Db::name($table)->useSoftDelete('deletetime')->count();
}else{
$count = Db::name($table)->where($where)->useSoftDelete('deletetime')->count();
}
return ceil($count/$limit);
}
... ... @@ -293,7 +297,15 @@ class Common
$arr['data'] = $res;
//总页数
$arr['total_page'] = self::countSoft('goods',$where);
if(empty($where)){
if($is_news == 1){
$arr['total_page'] = self::countSoft('goods',['is_new'=>0],$limit);
}else{
$arr['total_page'] = self::countSoft('goods','',$limit);
}
}else{
$arr['total_page'] = self::countSoft('goods',$where,$limit);
}
if(empty($flag)){
return $arr;
}else{
... ...