$sql="select a.*,b.name from obj_users_admin a left join obj_users_admin_groups b on a.gid=b.id";
$b=$num=2; //每页显示记录数
$page=input("get.page")?input("get.page"):1; //当前页
$count = Db::execute($sql); //总条数
$a=($page-1)*$b;
$sql2=$sql." limit $a,$b";
$list = Db::query($sql2); //当前页数据
$arr=Bootstrap::make($list,$num,$page,$count,false,['path'=>Bootstrap::getCurrentPath(),'query'=>request()->param()]);
print_r($arr);
print_r($arr->render());
徐多蔚亲测无误!
tp5中LEFT分页格式:
$a=config("database.prefix")."users_admin";
$b=config("database.prefix")."users_admin_groups";
$arr=$obj->db->table("$a a")
->join("$b b", "a.gid=b.id", 'LEFT')->where($tj)->field("a.*,b.name")->order("a.updatetime desc,a.id desc")->paginate(2,false, [
'query' => Request::instance()->param(),//不丢失已存在的url参数
]);
关注公众号,了解更多it技术(it问答网)