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));
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