php - cakephp assocations issue in 2x -


i have 2 tables

  • messages

  • users

users has roles doctor , user.

messages has doc_id & user_id.

how make association, returns me both data doc_id & user_id users.

for role association on user need join table, thats if right in believing user can have many roles?

you'r message model should have belongsto user, when doing loop ups use deep associations in find methods bring like...

// find deep assosiations $this->message->find('all', array());   array (     [message] => array         (             [id] => 2             [body] => example body...         )      [user] => array         (             [username] => john             [role] => array                 (                     [0] => 2                     [1] => 6                 )          )  )  

Comments