<dmitrybelyakov@yandex.ru> wrote:
>
> Hello.
>
> I don't know it might be me doing something wrong here, bat can you please
> point me to the correct way of doing this:
>
> I try to construct a simple SQl statement with Zend_Db_Select like this
>
> $select = $db->select();
> $select->from('table_name');
> $select->where("$field = ?", $value);
>
> It produces a query like this:
>
> SELECT `table_name`.* FROM `table_name` WHERE (field = 'yes')
>
> That gets returns an SQL error because field name in WHERE statement is not
> quoted. Correctly it should be like this:
>
>
> SELECT `table_name`.* FROM `table_name` WHERE (`field` = 'yes')
>
>
> Of course i can add quotes manually but my question is - is this correct
> behavior? Because all the examples in the documentation don't have quotes in
> WHERE statements.
>
Did you turn off AUTO_QUOTE_IDENTIFIERS?
In a nutshell, you could force:
http://files.zend.com/help/Zend-Framework/zend.db.html#zend.db.adapter.connecting.parameters.example2
Just use the example, and set it to true.
Regardless, you should use field names that do not conflict with
reserved words in SQL.
Till
没有评论:
发表评论