Possible duplicate:
PHP code to convert a MySQL query to a CSV file
What is the best and cleanest way to export a mysql query to CSV (for Excel 2003 and later)? The "best" from the point of view is tested, maintained, configured ... therefore, the ideal solution would be something like the standard PHP library .
It should correctly handle the shell, escaping, encoding, cr-lf, field names on the 1st line, ... etc.
There were a few questions about this here in SO (like this one ), but no one focuses on the properties I require above.
Some of my ideas:
- use
fputcsv ? (but encoding, escaping, and cr-lf , it would seem, could not be installed !) - extract code from phpmyadmin ...?
SELECT * INTO OUTFILE does not work on my server (access denied)system("mysqldump ...") impossible (secure hosting mode)
source share