I do the same thing for a lot of my tables and in most cases the
numbers get out of sync. Either a profile fails to create, or creates
dupes, or something terrible happens. Its best to just keep inserting
rows (and delete broken ones) then to try and fix the table to sync.
On Nov 1, 6:23 pm, "Dave Maharaj" <m...@davemaharaj.com> wrote:
> Everything has the ID field.
>
> My point is that create a User and Profile at the same time as in my case
> User.id is 123 for example and Profile.id is 123 also
>
> Why would I want to create Profile.id = 123 and Profile.user_id 123
>
> That's what I was getting to..redundant to have Profile.user_id if I'm
> setting up a hasOne no?
>
> My Profile hasMany Gallery which uses profile_id, basically everything is
> linked back to the Profile not the User (even though User and Profile are
> the share the same ID)
>
> If I am wrong just let me know.
>
> Dave
>
> -----Original Message-----
> From: Jean-Francois Bibeau [mailto:jfbib...@gmail.com]
> Sent: November-01-10 10:43 PM
> To: CakePHP
> Subject: Re: Anything wrong with this?
>
> Everything in your database should have an id column, regardless of if
> it's in a relationship or not. This is the only thing that can
> uniquely identify your row if you want to edit it, delete it,
> etc... :)
>
> Then, to follow cake conventions, any relationship should have a
> foreign key column of <parentmodel>_id . Following these conventions
> will make your life a 100 times easier in the long run, and is
> generally good practice!
>
> Cheers!
>
> On Nov 1, 8:58 pm, "Dave Maharaj" <m...@davemaharaj.com> wrote:
> > User hasOne Profile , Profile belongsTo User
>
> > But in my Profile table I do not have user_id, I just have id which is the
> > User.id created automatically when the User creates an account. To me it
> > seems like why give the Profile a separate ID when essentially its just an
> > extension of the User.
>
> > Everything else is related to the Profile
>
> > Profile:
>
> > var $belongsTo = array(
>
> > 'User' => array(
>
> > 'className' => 'User',
>
> > 'foreignKey' => 'user_id')
>
> > );
>
> > User:
>
> > var $hasOne = array(
>
> > 'Role' => array(
>
> > 'className' => 'Role',
>
> > 'foreignKey' => 'id',
>
> > 'dependent' => false),
>
> > 'Profile' => array(
>
> > 'className' => 'Profile',
>
> > 'foreignKey' => 'id',
>
> > 'dependent' => false)
>
> > );
>
> > Is this set up wrong?
>
> > Thanks,
>
> > Dave
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php?hl=en
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment