Had this code lying around for a bit, and fancied turning it into a plugin for all to use.
Merely add to a blank template like so:
{exp:csvee query="SELECT member_id, username, screen_name, email FROM exp_members"}
Navigate to your template and you should be presented with a downloadable CSV file.
Parameters:
query - The query from which the CSV output is determined.
fixed_width - If you want each column (field) to be a fixed width, supply an integer value in this parameter. By default it will pad those fields that are shorter with spaces. You can change this character with the pad_character parameter.
pad_character - Character used to pad fields that do not meet the fixed width column setting.
seperator - Custom seperator to use between fields. This defaults to a comma.
delimiter - Custom delimiter to encase each field. Defaults to a double quotation. e.g., “My field”
show_headings - Whether to show column headings. possible values are yes or no. Defaults to yes
filename - Desired filename of output file, defaults to “CSVee_Output.csv”
save_path - If you would rather save the output file to disk, use this parameter. You can use this in conjunction with the redirect parameter if you also want to download.
redirect - Where to send the user after visiting the template holding this plugin.
group_id - Pipe delimited ( 1|2|3 ) set of group ID’s if you want to restrict the download to certain member groups.
user_id - Same as above but by user ID.
Important Note:
To use whitespace characters in either of the pad_character/seperator/delimiter parameters just use their literal names, e.g., pad_char=“space” or pad_char=“tab”
Additional:
delete, drop, truncate, update, insert, alter, create
The use of any of these MySql commands will cause the plugin to quit out before issuing the query. This was added for security purposes.
Current Version: 1.1
