I have 3 tables; tbl_member, tbl_message, tbl_messageto.
tbl_member records user information.
tbl_message stores current user id, subject, time, and message
tbl_messageto stores record of tbl_message 2 times but with different id of memberId i.e.the same message is send 2 times, one for other user and the next one for the user himself.
Now I need to access all the record of particular member whose messageId =memberId .
My sql code is: [ "SELECT * FROM tbl_message m, tbl_messageto t, tbl_member u WHERE m.messageId=t.messageId AND m.authorId=t.memberId AND t.memberId=u.id AND u.id=7"])
I tried but I got errrors. And at last I compel to post in this blog.
Need your idea.
Below is the schema & relation for my table
tbl_member
id [PK]
password
name
tbl_message
messageId [PK]
authorId [current user’s id]
time
subject
text
[b]
[/b]
tbl_messageto
messageId [FK]
memberId [message receiver’s id]
authorId [message sender id i.e. current user’s id]
Message module
return array(
'messageto' => array(self::HAS_ONE,'Messageto','messageId'),
'member' => array(self::BELONGS_TO,'Member','authorId'),
);
Member module
return array(
'message' => array(self::HAS_MANY,'Message','authorId'),
);