I need to export a table named 'app_users' from my database, into a spreadsheet, a csv for example. How do I do this? Also, how do I send this file to browser? I am using Zend framework.
Per this answer you could run the following SQL query if you have direct access to the filesystem the db server is on:
SELECT *
FROM app_users
INTO OUTFILE '/tmp/app_users.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
EDIT: You'll probably also need to delete this file using php after it's created and served to the user, otherwise the next time the query above is run it might refuse to overwrite the file (that's the default).