<legend id='URLzH'><style id='URLzH'><dir id='URLzH'><q id='URLzH'></q></dir></style></legend>

      <small id='URLzH'></small><noframes id='URLzH'>

        <tfoot id='URLzH'></tfoot>
        • <bdo id='URLzH'></bdo><ul id='URLzH'></ul>
      1. <i id='URLzH'><tr id='URLzH'><dt id='URLzH'><q id='URLzH'><span id='URLzH'><b id='URLzH'><form id='URLzH'><ins id='URLzH'></ins><ul id='URLzH'></ul><sub id='URLzH'></sub></form><legend id='URLzH'></legend><bdo id='URLzH'><pre id='URLzH'><center id='URLzH'></center></pre></bdo></b><th id='URLzH'></th></span></q></dt></tr></i><div id='URLzH'><tfoot id='URLzH'></tfoot><dl id='URLzH'><fieldset id='URLzH'></fieldset></dl></div>

        如何使用 Zend 框架使用 mySQL 的 INTO OUTFILE 功能导出到 CSV

        How To Use Zend Framework To Export To CSV Using mySQL#39;s INTO OUTFILE Functionality(如何使用 Zend 框架使用 mySQL 的 INTO OUTFILE 功能导出到 CSV)
        <legend id='bSK5I'><style id='bSK5I'><dir id='bSK5I'><q id='bSK5I'></q></dir></style></legend>
          <tbody id='bSK5I'></tbody>

          <bdo id='bSK5I'></bdo><ul id='bSK5I'></ul>

                <i id='bSK5I'><tr id='bSK5I'><dt id='bSK5I'><q id='bSK5I'><span id='bSK5I'><b id='bSK5I'><form id='bSK5I'><ins id='bSK5I'></ins><ul id='bSK5I'></ul><sub id='bSK5I'></sub></form><legend id='bSK5I'></legend><bdo id='bSK5I'><pre id='bSK5I'><center id='bSK5I'></center></pre></bdo></b><th id='bSK5I'></th></span></q></dt></tr></i><div id='bSK5I'><tfoot id='bSK5I'></tfoot><dl id='bSK5I'><fieldset id='bSK5I'></fieldset></dl></div>
                <tfoot id='bSK5I'></tfoot>
              1. <small id='bSK5I'></small><noframes id='bSK5I'>

                • 本文介绍了如何使用 Zend 框架使用 mySQL 的 INTO OUTFILE 功能导出到 CSV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我希望使用 Zend Framework 将大量数据导出到 CSV 文件中以供用户下载.有什么方法可以使用 Zend_Db 的功能并使用INTO OUTFILE"语法将文件输出为 csv?基本上我希望能够调整我的 Zend_Db 模型以导出到一个 csv 文件而不是返回一个 PHP 数组.我想使用的 mysql 语法的一个例子是:

                  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" syntax to output the file as a csv? Basically I want to be able to adapt my Zend_Db models to export to a csv file instead of returning a PHP array. An example of the mysql syntax I want to use would be:

                  SELECT a,b,a+b INTO OUTFILE '/tmp/result.text' 
                  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' 
                  LINES TERMINATED BY '
                  ' 
                  FROM test_table; 
                  

                  推荐答案

                  您可以尝试构建一个基本查询,将其转换为字符串,然后从那里追加.优点是您可以使用 Zend 的绑定功能(至少对于 where 子句),以防万一.像这样:

                  You can try to build a base query, convert it to a string and then append from there. The advantage being that you can use Zend's bind functionality (at least for the where clause), in case you need that. Like so:

                  $filename = 'tmp/test.csv';
                  $value = 'given';
                  
                   // build base query making use of Zends binding feature.
                  $select = $this->_db->select()
                      ->from(test_table, array(a,b,a+b))
                      ->where('column = ?', $value)
                      ->__toString()
                  
                   // append the rest of the query.
                  .' INTO OUTFILE "'. $filename .'"'
                  .' FIELDS TERMINATED BY ";"'
                  .' OPTIONALLY ENCLOSED BY "\""'
                  .' LINES TERMINATED BY "\n"';
                  
                   // execute query.
                  $this->_db->query($select);
                  

                  这篇关于如何使用 Zend 框架使用 mySQL 的 INTO OUTFILE 功能导出到 CSV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
                  Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                  <legend id='ddZms'><style id='ddZms'><dir id='ddZms'><q id='ddZms'></q></dir></style></legend>
                  • <bdo id='ddZms'></bdo><ul id='ddZms'></ul>
                  • <i id='ddZms'><tr id='ddZms'><dt id='ddZms'><q id='ddZms'><span id='ddZms'><b id='ddZms'><form id='ddZms'><ins id='ddZms'></ins><ul id='ddZms'></ul><sub id='ddZms'></sub></form><legend id='ddZms'></legend><bdo id='ddZms'><pre id='ddZms'><center id='ddZms'></center></pre></bdo></b><th id='ddZms'></th></span></q></dt></tr></i><div id='ddZms'><tfoot id='ddZms'></tfoot><dl id='ddZms'><fieldset id='ddZms'></fieldset></dl></div>
                        <tbody id='ddZms'></tbody>

                    • <small id='ddZms'></small><noframes id='ddZms'>

                        <tfoot id='ddZms'></tfoot>