I’m trying to get some data from a join table in a many-to-many relationship in a cgridview.
I have 3 tables: user, card, and user_card. User has an ID and some data, card has an ID and a set_id and some data, user_card has an id, a user_id, a card_id, and a quantity field. So a user can have a card with a quantity associated with it.
There is a model for the User and Card tables with many-to-many relationships set up in them.
The data I want to get is all cards within a set and then display them with the quantity the logged in user has. The SQL for this would be SELECT * FROM card LEFT JOIN member_card ON card.id = member_card.card_id AND member_card.member_id =1 WHERE set_id =1;
It seems I can’t create a cgridview that would allow me to access both the card data with the data from the user_card quantity field. Is it possible to do this?