tp5.1 layui 数据太多造成列表读取错误(内存溢出)

原来错误写法:

$list=Db::name('log')->field('id,title,content,username,time,controller')->where($where)->order($od)->limit($limit)->page($page)->select();
$list2=Db::name('log')->field('id')->where($where)->select();
$count=count($list2);//取得记录集总条数

$list2=Db::name('log')->field('id')->where($where)-->select()

这种用法,就是再重新查一次,太费资源了

 

正确写法:

用count()统计数量,官方教程:https://www.kancloud.cn/manual/thinkphp5_1/354028

$count=Db::name('log')->where($where)->count();//取得记录集总条数

$list=Db::name('log')->field('id,title,content,username,time,controller')->where($where)->order($od)->limit($limit)->page($page)->select();
$count=Db::name('log')->where($where)->count();//取得记录集总条数

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值