Jump to content

PDO export to CSV.


synking

Recommended Posts

Hey guys,  Just have a question as i looked on google but didn't find too much.

 

I want to export a table to CSV so that it can be opened in excel and edited if needed.

 

But the question is using PDO, would it be better for mysql to create this csv with a intofile query or should i have php use the fputcsv functions.

 

I have not seen much on using that with pdo so i thought i would see what everyone thought.

Link to comment
https://forums.phpfreaks.com/topic/267388-pdo-export-to-csv/
Share on other sites

INTOFILE would most likely be more efficient, but would be MySQL-specific.

 

If you want to take full advantage of the abstraction PDO gives you, I'd bring the data into PHP and parse it there - you can easily do this with ANSI/ODBC standard code.

 

If you only plan on using MySQL, and want to maximize efficiency around this, then use INTO OUTFILE

Link to comment
https://forums.phpfreaks.com/topic/267388-pdo-export-to-csv/#findComment-1371266
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.