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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.