$totalcount = pdo_fetchcolumn("select count(id) from ".tablename('ewei_shop_order').' where uniacid='.$uniacid);
$pagecount = 1000;
set_time_limit(0);
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=全部订单-".date('Y-m-d-H-i-s').".csv");
ob_start();
ob_end_clean();
echo "\xEF\xBB\xBF";
~~~
- 设置导出标题字段,并循环输出
~~~
$head = array('openid','粉丝昵称');
$fp = fopen('php://output', 'a');
fputcsv($fp, $head);
for($i=0;$i<intval($totalcount/$pagecount)+1;$i++){
$sql="";
$sql .= ' LIMIT ' . strval($i*$pagecount) . ',' . $pagecount;
$list = pdo_fetchall($sql);
foreach($list as &$row){
$export = array($row['openid'],$row['nickname']);
fputcsv($fp, $export);
}
unset($row);
}
~~~