So, i’ve come up with this query wich works perfectly fine when executed. However, since I want to use the pagination from Zend, the query has to be through an adapter.
This is the query that has to be converted: (i’ve cut the query so only the important part is here. I am aware of the fact that you can’t run this query LOL)
//snip
WHERE
city IN (
SELECT
Plaatsnaam
FROM
plaatsnamen
WHERE
Latitude
BETWEEN
?
AND
?
AND
Longitude
BETWEEN
?
AND
?
)
//snip
Works perfectly fine! However.. As you can see, i’m using an “advanced” WHERE IN case. Somehow, i can’t get this converted and i’m stuck.
This is what it has to be converted to:
$db = Zend_Db_Table::getDefaultAdapter();
$select = $db->select('gethousecity.id, city')
->from('gethousecity')
->join('houses_props', 'houses_props.id = gethousecity.id')
->where('city IN ()') // HOW TO CONVERT THE UPPER QUERY TO FIT IT HERE?
->where('is_online = 1')
->where('houses_props.prop_name = ?', 'something')
->where('houses_props.prop_value BETWEEN ? AND ?', array(1,2));
I haven’t found any documentation at all on how to convert the query into some format that fits here. Does anyone have any idea? Mostly because I need to insert some values and ZF is rewriting some weird shit there.
I’m kinda stuck now, any help would be awesome!
Subqueries work just fine.
If the problem is the complex where, than you can use named parameters.
Returns:
Which should work with named parameters, as seen in manual