当前位置:网站首页>php关于数据量大导出数据或者遍历数据导致内存溢出超时等问题
php关于数据量大导出数据或者遍历数据导致内存溢出超时等问题
2022-07-28 15:22:00 【孙奋斗】
**
php关于数据量大导出数据或者遍历数据导致内存溢出超时等问题
**
话不多说直接上代码
$p = 0;$pageSize=100; // 定义每页显示条数
set_time_limit(0);//这是个神仙函数很赞,其主要作用是 :设置脚本最大的执行时间,单位为秒。如果设置为0(零),没有时间方面的限制。
while (
$list = db('user')->order('a.id desc')->limit($p*$pageSize, $pageSize)->select()//获取每页的数据,拆分开
) {
foreach ($list as $k=>$v) {
// 以下内容是导出的列表内容复制可以省略
$index = $k + $p * $pageSize + 3;
// switch ($v['type']) {
// case 1:
// $lx = '线上订单';
// break;
// case 2:
// $lx = '线下订单';
// break;
// default:
// $lx = '';
// }
// $address = json_decode($v['address'], true);
$objPHPExcel->getActiveSheet()
->setCellValue('A'.$index, $v['uname'])
->setCellValue('B'.$index, $v['bid'].' ')
->setCellValue('C'.$index, $v['pid'].' ')
->setCellValue('D'.$index, $v['amount'].' ')
->setCellValue('E'.$index, $v['f_amount'].' ')
->setCellValue('F'.$index, $v['open_bank'])
->setCellValue('G'.$index, ' '.$v['card_number'].' ')
->setCellValue('H'.$index, $v['jg_name'].' ')
->setCellValue('I'.$index, ' '.$v['jg_number'].'')
->setCellValue('J'.$index, ' '.$v['id_card_code'].'');
$objPHPExcel->getActiveSheet()->getRowDimension($index)->setRowHeight(16);
}
$p++;//页码增加
}
不懂可以转行了!
边栏推荐
- Use py to automatically generate weekly reports based on log records
- R语言使用fs包的file_delete函数删除指定文件夹下的指定文件、举一反三、dir_delete函数、link_delete函数可以用来删除文件夹和超链接
- Record doc
- A good start
- 深部位移监测系统wk813应用边坡、大坝、堤防、铁路和建筑基坑开挖等深部位移测量
- LabVIEW Linx toolkit controls Arduino equipment (expansion-1)
- js 优先级队列
- JS queue
- Record Clearfix clear float
- 1. Simple command line connection to database
猜你喜欢

2021 Kent interview question 3

Common problems and precautions of remote serial port server (adapter) uart/i2c/1-wire/spi PS304

js 双向链表 01

Advantages of optical rain gauge over tipping bucket rain gauge

IT远程运维是什么意思?远程运维软件哪个好?

Telecommuting can be easily realized in only three steps

2021 肯特面试题3

js 栈

远距离串口服务器( 适配器)UART/I2C/1-Wire/SPI PS304常见问题及注意事项

2021 Yahong pen test question 2
随机推荐
CoDeSys realizes bubble sorting
A tour of grp:05 - GRP server streaming service end stream
NTC, PT100 thermal resistance to 4-20mA temperature signal converter
软件问题修复跟踪系统实战开发教程(上篇)
Baidu editor ueeditor, when editing too much content, the toolbar is not visible, which is not convenient for editing or uploading problems
疫情红利消失,「居家健身」泡沫消散
el-input限制只能输入规定的数
Connection and application of portable borehole inclinometer data acquisition instrument and inclinometer probe
Deeply understand the fusing configuration of istio traffic management
js 栈
2021 肯特面试题3
JS linked list 01
我在上海偶遇数字凤凰#坐标徐汇美罗城
VM501开发套件开发版单振弦式传感器采集模块岩土工程监测
软考 系统架构设计师 简明教程 | 软件调试
2021 亚鸿笔试题
使用py,根据日志记录自动生成周报
2021 亚鸿笔试题2
R language uses ggpairs function of ggally package to visualize pairwise relationship graph of grouping multivariable, set alpha parameter to change image transparency, diagonal continuous variable de
跳表的实现