One part of my query is EXISTS condition:
$select->where(
'EXISTS(' .
'SELECT `price_property_id` FROM `property_price` ' .
'WHERE `price_property_id` = `pu_property_id`' .
' AND `price_value` >= ' . $params['price_min'] .
' AND `price_value` <= ' . $params['price_max'] .
')'
);
How it writes in right way in Zend Framework?
As far as I know, Zend_Db_Select
doesn't have specific methods to include subqueries in the where
clause. I think you cannot improve it any further, the way it's written.
You might rewrite the subquery as an OUTER JOIN
, and you'd be able to leverage some more Zend_Db_Select
methods, but I'm not sure about the advantages of doing it, as far as your code is working and clear to read.
Hope that helps,