ZF-9964: SQLSTATE[42703]: camel case is used for column names in database, exception occurs when such column names are used in where clause



I am coming across problem with Zend Framework, version 1.9

Message: SQLSTATE[42703]: Undefined column: 7 ERROR: column "shortname" does not exist LINE 1: SELECT "publisher".* FROM "publisher" WHERE (shortName = 'fs... ^

Perspective: I am using postgreSQL PDO and for column names camel notation is used.

Code View: $select = $this->getDbTable()->select(); $select->from('publisher'); $select->where("shortName = ?", $shortName); $select->order('id DESC'); $resultSet = $this->getDbTable()->fetchAll($select);

When I use lower case for column names, this exception doesn't occur. At this point it is very hard to change case for all columns of database. Any way around for this? Your response will be much appreciated!

Thanks, Nabeel


Use autoQuoteIdentifiers = false (see manual)

You should use the method Zend_Db_Adapter_Abstract:>quoteIdentifier()

$db = $this->getDbTable()->getAdapter();
$columnName = $db->quoteIdentifier('shortName');
$select->where("$columnName = ?", $shortName);

Doubt about use of components please direct support requests to either the mailing list, or #zftalk on IRC ;).