By I am learning on
Hi,
In a function I wrote:
$select_query = "SELECT * INTO OUTFILE 'mytable.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' FROM {my_table};";
db_query($select_query);
It works fine and creates the file in my XAMPP c:\xampp\mysql\data\mywebsite
1. Is there a better way doing this in Drupal?
2. How do I specify path e.g. /sites/default/files so that it is created there.
3. How do I start a file download the moment it is ready?
Regards
Comments
Here is a standalone page I
Here is a standalone page I created to download an excel sheet of a mysql database table. You will have to change it a bit for use in drupal but perhaps it will help you out a bit.
Thanks saepl, I too know
Thanks saepl,
I too know plain PHP implementation of this and looping and adding record by record. But dumping by select * into .... is much faster then looping a recordset especially when you have bulk data (as in my case, almost a million records in a table).
I'm searching for a Drupal implementation of the same, I'm studying table_export (although a drupal 5 module, I need code for drupal 6) for the same, this is also looping the recordset.
Regards
maybe use the header
maybe use the header information in my code and use the inject module to insert the header into your theme?
http://drupal.org/project/inject