当前位置:网站首页>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++;//页码增加
}
不懂可以转行了!
边栏推荐
- 使用js直传oss阿里云存储文件,解决大文件上传服务器限制
- Ask if you don't understand, and quickly become an advanced player of container service!
- mysql 查看事件状态语句和修改办法
- Numpy ndarray learning < II > miscellaneous records
- Record Clearfix clear float
- 正大杯黑客马拉松数据解析竞赛
- R language ggplot2 visually draws line plots, and uses gghighlight package to highlight the lines that meet the combination judgment conditions in the line graphs (satisfies both condition a and b)
- 一大早支付宝来短信说你中“奖”了?处理服务器挖矿病毒 - kthreaddi
- 为什么学编程的人大多数都去了深圳和北京?
- I came across Digital Phoenix coordinate Xuhui Meiluo city in Shanghai
猜你喜欢

5 亿用户,比微信还早四年……这个运营了 15 年的 APP 即将永久停服

我在上海偶遇数字凤凰#坐标徐汇美罗城

About standard IO buffers

Thoughts on solving the pop-up of malicious computer advertisements

12V pulse speed measurement to 24V level signal conversion transmitter

500million users, four years earlier than wechat... This app, which has been in operation for 15 years, will be permanently discontinued

Wei Jianjun couldn't catch up with Li Shufu by riding a BMW

2021 Kent interview question 1

js 优先级队列

Temperature measurement and imaging accuracy of ifd-x micro infrared imager (module)
随机推荐
Note: the value is rounded up to ten, hundred, thousand, ten thousand
The deep displacement monitoring system wk813 is used to measure the deep displacement of slopes, dams, embankments, railways and building foundation pit excavation
Vm501 development kit development version single vibrating wire sensor acquisition module geotechnical engineering monitoring
Writing of factorial
远距离串口服务器( 适配器)UART/I2C/1-Wire/SPI PS304常见问题及注意事项
深部位移监测系统wk813应用边坡、大坝、堤防、铁路和建筑基坑开挖等深部位移测量
Let's learn the game of beating hamsters
Roson的Qt之旅#101 Qt Quick中的模型和视图
2021-10-21 notes
李宏毅《机器学习》丨5. Tips for neural network design(神经网络设计技巧)
Remember the common JS methods of projects
Stm32f103c8t6 + 0.96 "I2C OLED display 3d_cube
Application of optical rain gauge to rainfall detection
Implementation of skip table
js 链表 01
关于标准IO缓冲区的问题
Use py to automatically generate weekly reports based on log records
el-input限制只能输入规定的数
RF module wireless transceiver rf63u chip application data transmission and infrastructure network
Sudden! MSI CEO Jiang Shengchang fell to death