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

Issue Type: Bug Created: 2010-06-08T11:42:10.000+0000 Last Updated: 2010-07-15T01:54:11.000+0000 Status: Resolved Fix version(s): - 1.10.7 (28/Jul/10)

Reporter: Nabeel Mushtaq (nabilmushtaq) Assignee: Ramon Henrique Ornelas (ramon) Tags: - Zend_Db

Related issues: Attachments:



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


Posted by Mickael Perraud (mikaelkael) on 2010-07-15T01:42:33.000+0000

Use autoQuoteIdentifiers = false (see manual)

Posted by Ramon Henrique Ornelas (ramon) on 2010-07-15T01:52:49.000+0000

You should use the method Zend_Db_Adapter_Abstract:>quoteIdentifier()

<pre class="highlight">
$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 ;).

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.