TP5 sql多条件去重后分页


use think\paginator\driver\Bootstrap;

$page=request()->get('page');
$num = 10; //分页个数
$page = $page ? $page : 1; //当前页
$limit=($page-1)*10;
$sql = "SELECT * from ywy_call_log a where id in (SELECT max(id) from ywy_call_log group by user_id,shop_id ) LIMIT {$limit},{$num}";
$count_sql = "SELECT * from ".config('database.prefix')."call_log a where id in (SELECT max(id) from ywy_call_log group by user_id,shop_id )";
$back = Db::query($sql);
$count_back = Db::query($count_sql);
$count = count($back);
$need = Bootstrap::make($back, $num, $page, $count, false, ['path' => Bootstrap::getCurrentPath(), 'query' => request()->param()]);

posted on 2021-03-31 15:38  *孤独的夜行者*  阅读(385)  评论(0编辑  收藏  举报

导航