jagguy
asked on
cakephp association confusion
Hi,
I have a simple question on associations in cakephp.
I have a user , role and tutor table.
The issue is how do i define this where I have a admin user who can view tutors but there is no tutor entry with this user? Or do I need to bother as not all users are tutors anyway.
I can create a user that is a tutor and have the userID in the tutor table as a foreign key.
The role is the user type like admin, tutor etc which is linked to the user.
http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html
I have a simple question on associations in cakephp.
I have a user , role and tutor table.
The issue is how do i define this where I have a admin user who can view tutors but there is no tutor entry with this user? Or do I need to bother as not all users are tutors anyway.
I can create a user that is a tutor and have the userID in the tutor table as a foreign key.
The role is the user type like admin, tutor etc which is linked to the user.
public $belongsTo = array(
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id'
)
);
public $hasOne = array(
'Tutor' => array(
'className' => 'Tutor',
'dependent' => true
)......
http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.