Please help me.
I am having three tables as,
Users:id,name....
Message:id,title....
Messages_Users:id,message_id,sender_id,receiver_id......
So i am using HABTM relation in message model for this as,
var $hasAndBelongsToMany = array(
'Users' => array (
'className' => 'User',
'join_table' => 'messages_users',
'foreignKey' => 'message_id',
'associationForeignKey' => 'reciever_id',
'conditions'=> array('MessagesUser.reciever_id => $this->Session->read("Id")')
)
);
So now i want to write a sql query to fetch the name of all the friends of the user who has sent messages to that particular logged in use.
i,e....when the user log in he will get list of messages he got along wid the name of the senders.
how to write query for this in messages_controller??
please let me if anybody is having any idea..