I'm writing a PHP application using zend framework 2.2.2. I'm trying to create a select query with a join that contains a static value condition.
this is my code:
$this->select->join('global_image_link','global_image_link.table_pkey=drink_flavor.drink_flavor_id AND global_image_link.global_image_type_id=2',array())
now the end of the query contains the following:
global_image_link.global_image_type_id=2
when i do getSqlStringForSqlObject to return the query the end of the query is
AND `global_image_link`.`global_image_type_id`=`2`
because it adds `` to the number it searches for column called 2 instead of the number 2.
I guess i need to escape that number somehow or wrap it with some class.
any ideas how to resolve the issue?
thanks
Try to use new Zend_Db_Expr like that:
$this->select->join('global_image_link',new Zend_Db_Expr('global_image_link.table_pkey=drink_flavor.drink_flavor_id AND global_image_link.global_image_type_id=2'),array())
Zend_Db_Expr does not escape values, so be careful when using it.