I am new to Zend Framework 2 and I am trying to hook my table up to TableGateway and do a basic select that should look like:
SELECT * FROM <tableName> WHERE QMQT# = 1
It looks like this in my table model:
$rowset = $this->tableGateway->select(array('QMQT#' => $id));
The problem seems to be the # sign in the query as I get an error back:
SQLSTATE[42S22]: Column not found: 0 [IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0206 - Column "QMQT""#" not in specified tables. (SQLPrepare[0] at ext\pdo_odbc\odbc_driver.c:206)
I can prepare and execute this query fine in plain PDO, but running it through Zend's TableGateway gets me this error. Are pound/number signs not allowed in table names in Zend? Is there a way to bypass this excessive escaping?
Thank you for any suggestions...
Edit:
I have also tried the quoteIdentifier() function to try to fix this:
$rowset = $this->tableGateway->select(array($this->tableGateway->getAdapter()->getPlatform()->quoteIdentifier('QMQT#') => $id));
But all it does is give me this error:
SQLSTATE[42000]: Syntax error or access violation: 0 [IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0104 - Token QMQT was not valid. Valid tokens: < > = <> <= !< !> != >= �< �> �= IN NOT. (SQLPrepare[0] at ext\pdo_odbc\odbc_driver.c:206)
Have you tried using Expressions?
$rowset = $this->tableGateway->select(array(
new Zend\Db\Sql\Expression\Expression('QMQT# as bob')
));