Good day, comrades, Zend_Db_Select has methods such as join (), joinleft (), etc. I really have not yet learned how to work with them, so I ask for help. You need to properly wrap this SQL query:

SELECT sub. * , mail. * FROM `ListItem` AS list JOIN `SubscriberData` AS sub ON list.SubscriberID = sub.id JOIN `MailData` AS mail ON list.MailID = mail.id JOIN `TagsListItem` AS tags ON list.id = tags.ItemID WHERE list.UserID =666 AND tags.TagID =3 

Help please, but for now it works through the usual $ db-> query (), but this is not good.

    1 answer 1

    I figured it out myself, here’s the final version of the request wrapped in Zend_Db_Select:

     $select = $db->select() ->from(array('list' => 'ListItem'), array()) ->join(array('sub' => 'SubscriberData'), 'sub.id=list.SubscriberID', array('*')) ->join(array('mail' => 'MailData'), 'mail.id=list.MailID', array('*')) ->join(array('tags' => 'TagsListItem'), 'tags.Itemid=list.id', array()) ->where('list.UserID=?', '666') ->where('tags.TagID=?', '3'); $result = $select->query()->fetchAll(); 
    • Here it is a worthy answer to your own question. If people in this forum continued to try and do it on their own, it would be cool. just +1 for doing it myself! - Artem
    • Shrek, thank you :) Just for me, in this case there was no choice, like in many others :) You need to do it, there is a tool, someone succeeded, there is documentation ... So you need to dig and understand, especially since I myself am interested and will come in handy in the future. :) - Shamanis