Ok Im still new to Zend, and trying to find how the ORM works in general for it, seems to be posing a difficult task (anyone know where they have a specific document for it). That aside what I am trying to do is take an existing query and add a "AND" clause to it. Just not sure how to go about doing that, as the examples I have found else where dont look like this one, and I'd rather avoid breakage on this
$select = $this->select()
->from('offer_term')
->setIntegrityCheck(false)
->joinUsing('term_mapping', 'term_id')
->where('promo_id = ?', $promo_id);
return $this->fetchAll($select);
Actually this is really easy once you start understand how Zend_db works.
your query:
you are already using the
select()
object for performing the query, so try refactoring to something like this(I'll include how do it with a conditional as well):Adding an AND in a
select()
query is done just by adding anotherwhere()
to the chain. This can be done by chaining as your original query does or by using separate statements as I have done. If you need to use the OR operator inselect()
query you can use theorWhere()
method.You can mix chaining and separate statements as needed, which makes adding a conditional pretty easy.
NOTE: Zend_Db is not an ORM, it is an implementation of The table gateway and table row patterns (I hope I got the names correct). So please do not expect full ORM functionality.
Hope this helps.
Try:
And remember to using manual.