tags:

views:

21

answers:

1

Hi, what's the best way in cakephp to get a list of private messages for a user considering my messages table is something like:

id: row id

left:sender id

right: receiver id

subject and text

with a find all i'll get the results with the user id but i want to display the username, ofcourse i could use a query with a join but probably there's a better way

thankyou

A: 

Hi,
Here's the plan:

  1. You need to link your private messages table to the user, by using a user_id field.
  2. Link the models via a belongsTo in the message private model.
  3. Just perform a Privatemessage->read() from the current user, you'll get the data in a privatemessage array

Hope this helps,
Nicolas.

Nicolas