I need to implement a simple functionality whereby agents can add members to a list of favourites. The way I believe this needs to be done is by having a table called ‘favourites’ with fields:
id
agent_id
member_id
Now I have the following questions:
-
Do we still need the ‘id’ field for this to work in Yii/CGridView?
-
What is the best way to get the total number of agents that a member has been favourited by? Should we store a value in the member record and update it each time a agent adds/removes the member from their favourites list? Or should we perform a count() query on the favourites table each time we need to know the value?
-
How can this be extended so that agents can add members to different favourite lists? A member can be part of multiple lists.