How To Use Zend Framework To Export To CSV Using mySQL's INTO OUTFILE Functionality

前端 未结 2 1357
一生所求
一生所求 2021-01-22 00:59

I am looking to export a large amount of data into a CSV file for user download using Zend Framework. Is there any way to use Zend_Db\'s functionaity and use the \"INTO OUTFILE\

2条回答
  •  不要未来只要你来
    2021-01-22 01:32

    Using a Zend_Db $db you can put any request directly:

    $db->query($exportquery);
    

    Note that you'll need the FILE privilege on the user used on the DB connection, it's a very high privilege (only root on some versions of MySQL edit: must be set for all databases on the server). So this should not be your main MySQL connection, the best thing would be to open the special high privilege connection only in the specific code needed for the OUTFILE query.

提交回复
热议问题