我要使用mysql查询导出的用户表中有400万条记录...一切正常。首先,我将分享我的代码:-
$query = <<<QUERY
SELECT 'id', 'name', 'email'
UNION ALL
SELECT id, name, email FROM users INTO OUTFILE "G:\users.csv"
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY "\n"
QUERY;
//my above code is creating csv file in just seconds.
//Code for download file
DB::connection('mysql')->statement($query);
header('Content-type: text/csv');
header('Content-disposition: attachment; filename=users.csv');
readfile('G:\users.csv');
unlink('G:\users.csv');
exit();
现在的问题是我给了G:\ users.csv路径,但是某些其他客户端系统没有该G:驱动器,那么它将产生问题。我想提供一些在所有系统中都可以访问的路径。.我给出的C:\ users.csv无法正常工作... 注意:-我不想在laravel中进行导出,因为它会使我执行超时。.因此,任何人都可以帮助您解决仅路径问题。休息一切正常。