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

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

报告相同问题?

悬赏问题

  • ¥50 关于#html5#的问题:H5页面用户手机返回的时候跳转到指定页面例如(语言-javascript)
  • ¥15 无法使用此凭据登录,因为你的域不可用,如何解决?(标签-Windows)
  • ¥15 yolov9的训练时间
  • ¥15 二叉树遍历没有报错但无法正常运行
  • ¥15 在linux系统下vscode运行robocup3d上场球员报错
  • ¥15 maven环境配置后无法运行mvn -v
  • ¥15 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿
  • ¥15 srs-sip外部服务 webrtc支持H265格式