In the definition , TableData Gateway processes only one table.
ZF sets this definition with integrity checking to Zend_Db_Table_Selects. However, integrity checking can be turned off, and then you can perform the joins. Just create a method inside your table class to do the Join via the select object as follows:
public function findByIdAndJoinFoo($id) { $select = $this->select(); $select->setIntegrityCheck(false) // allows joins ->from($this) ->join('foo', 'foo.id = bar.foo_id'); return $this->fetchAll($select); }
If you want to stick to the definition, you can use some level of service or DataMapper , which knows how to handle multiple tables. They are located between the Db classes and the controllers.
Another alternative is to use Joins, but table relationships , and then lazy load-dependent rows as needed. Of course, this is not a Union, but a few queries.
And finally, you can still use Zend_Db_Statement and create your SQL manually :
$stmt = $db->query( 'SELECT * FROM bugs WHERE reported_by = ? AND bug_status = ?', array('goofy', 'FIXED'));
source share