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

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

报告相同问题?