There seem to be several different ways to join the two tables using the Zend Framework, but I have never done this before, so I donβt know which one is best to do.
This is what I'm trying to do ...
I have 3 tables in my database:
users
( id , name )
groups
( id , name )
group_members
( id , group_id , user_id )
I am trying to find the groups the user belongs to and display them for the user. This SQL statement pretty much does the job (although there may be a better way to write it). It returns only those columns that are associated with group identifiers and name.
SELECT groups.id, groups.title
FROM group_members
INNER JOIN groups
ON groups.id = group_members.group_id
WHERE user_id = $userId
How can I do this using the Zend Framework?