OK I made the bookmarks table. So the model Bookmark looks like
var $belongsTo = array(
'User' => array('className' => 'User',
'foreignKey'
=> 'user_id',
'conditions'
=> '',
'fields' =>
'',
'order' =>
''
),
'Post' => array('className' => 'Post',
'foreignKey'
=> 'post_id',
'conditions'
=> '',
'fields' =>
'',
'order' =>
''
)
);
CREATE TABLE `bookmarks` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`created` DATE NOT NULL ,
`modified` DATE NOT NULL ,
`user_id` INT( 10 ) NOT NULL ,
`job_id` INT( 10 ) NOT NULL ,
`title` VARCHAR( 255 ) NOT NULL ,
`link` VARCHAR( 255 ) NOT NULL
) ENGINE = innodb;
Does this look right? I thought ther would be some complicated relationship
between the JOB / TEACHER / STUDENT
Thanks
Dave
-----Original Message-----
From: brian [mailto:[email protected]]
Sent: March-08-09 3:58 PM
To: [email protected]
Subject: Re: Model Relationships
Create a Bookmark model and associate it with User:
id
created
modified
user_id
post_id
title
link
On Sun, Mar 8, 2009 at 1:58 PM, Dave Maharaj :: WidePixels.com
<[email protected]> wrote:
> I am stumped on setting up model relationship for my site.
> I am building an education site with 4 user groups. The 2 in question
> are STUDENTS and TEACHERS. How I have set it up there are 2
> registration forms to create the USER (TEACHERS or STUDENTS) so on
> sign up it creates the USER and TEACHER_PROFILE or USER and
> STUDENT_PROFILE (I set it up this way because the profiles have
> completely different information)
>
> TEACHERS can add a posts / article
> STUDENTS can read the posts / articles but I want to have it so a
> STUDENT can bookmark a TEACHERS article. So what table do I need to
> create and the fields I would need? I know the STUDENT TABLE needs a
> join table but cant quite figure out the way to set it up. Do I need a
> students_posts table with:
> ID, student_id, post_id then link it up in the STUDENT MODEL?
>
> TEACHER MODEL:
> $belongsTo = array(
> 'User' => array('className' => 'User',
> 'foreignKey' => 'user_id',
> 'conditions' => '',
> 'fields' => '',
> 'order' => ''
> ),
> 'Group' => array('className' => 'Group',
> 'foreignKey' => 'group_id',
> 'conditions' => '',
> 'fields' => '',
> 'order' => ''
> ),
>
> var $hasMany = array(
> 'Post' => array('className' => 'Post',
> 'foreignKey' => 'teacher_id',
> 'dependent' => false,
> 'conditions' => '',
> 'fields' => '',
> 'order' => '',
> 'limit' => '',
> 'offset' => '',
> 'exclusive' => '',
> 'finderQuery' => '',
> 'counterQuery' => ''
> )
> );
>
> STUDENT MODEL:
> $belongsTo = array(
> 'User' => array('className' => 'User',
> 'foreignKey' => 'user_id',
> 'conditions' => '',
> 'fields' => '',
> 'order' => ''
> ),
> 'Group' => array('className' => 'Group',
> 'foreignKey' => 'group_id',
> 'conditions' => '',
> 'fields' => '',
> 'order' => ''
> )
> );
>
> Dave
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---