dongzong1866 2014-04-07 14:38
浏览 47
已采纳

Zend Framework 2'quote_identifiers'=> false

So i was planning my Application when i've encountered the following issue: i want to be able to make this query using Zend Db Select:

SELECT COLUMN_NAME AS COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'brand' AND TABLE_SCHEMA = 'product'

that selects the colums from a table. The problem is that Zend generates:

SELECT COLUMN_NAME AS COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'brand' AND TABLE_SCHEMA = 'product'

with "``"(quotes) on INFORMATION_SCHEMA.COLUMS that produces a SQL error of "No database selected". I've tried to insert " 'platform_options' => array('quote_identifiers' => false)," in my configuration array but nothing happens. The code used to generate that is:

    $sql = new Sql($this->adapter);
    $select = $sql->select();
    $select->columns(array('COLUMN_NAME'),false);
    $select->from('INFORMATION_SCHEMA.COLUMNS');
    $select->where(array('TABLE_NAME' => $table,'TABLE_SCHEMA' => $database));
    $statement = $sql->prepareStatementForSqlObject($select);
    var_dump($sql->getSqlStringForSqlObject($select));
  • 写回答

1条回答 默认 最新

  • duanhua5523 2014-04-14 06:33
    关注

    Back with you on this issue, I managed to find an answer for prefixing tables with the schema name. Here you can find the issue described and the solution seems to be the Zend TableIdentifier. So, to make a small conclusion the solution for the information schema / tables / columns is Metadata and for prefixing with a schema name is Table identifier.If you CAN'T remove the quotes just use one of these solutions

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制