因为据我所知,Doctrine没有OUTFILE功能,如何将查询导出为CSV文件?
例如,在MySQL中,查询将是:
SELECT * INTO OUTFILE 'file.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM table;
如何用Doctrine完成同样的工作?
答案 0 :(得分:0)
在伪代码中,我会这样:
FETCH records in Doctrine_Core::FETCH_NUM mode
foreach records as record:
save record in csv using fputcsv
参考文献:fputcsv
答案 1 :(得分:0)
如果对大量数据执行此操作,则内存不足。