-- José de Menezes Soares Neto <[EMAIL PROTECTED]> wrote
(on Thursday, 26 June 2008, 01:36 PM -0300):
> Hi friends,
>
> I did this join and it works well:
>
> $db = Zend_Registry::get('db');
> $select = $db->select()
> ->from('user')
> ->join(array('pro' => 'profile'), 'user.usr_id =
> pro.pro_usrid')
> ->where($w_query);
>
> $stmt = $select->query();
> $estoques = $stmt->fetchAll();
>
> But I really don't know what to do when I need more than one join...
>
> table 1 - user (pk: usr_id)
> table 2 - profile (pk: pro_id fk: pro_usrid)
> table 3 - address (pk add_id fk: add_usrid)
>
> I need to join table 1 with table 2 and table 1 with table 3
>
> any suggestions?
Execute multiple join statements:
$select->from('user')
->join(array('pro' => 'profile'), 'user.usr_id = pro.pro_usrid')
->join(array('a' => 'address'), 'user.usr_id = a.add_usrid')
->where($w_query);
Many of the methods in a select object can be executed multiple times,
with the result that they are aggregated (try it with where(), order(),
group(), and having() as well).
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/