Thursday, September 2, 2010

Re: hasOne: Saving related models

Ahhh i see :) thanks a lot!

On 2 Sep., 15:04, cricket <zijn.digi...@gmail.com> wrote:
> On Thu, Sep 2, 2010 at 1:55 PM, DerBjörn <b.unkh...@googlemail.com> wrote:
> > Hi,
>
> > I have a table 'users' and a table 'profiles' in hasOne relation
> > (table 'profiles_users').
> > At the same time i save a user i want also save his profile. I
> > searched and found the other here:
> >http://book.cakephp.org/view/84/Saving-Related-Model-Data-hasOne-hasM...
>
> > Now a profile gets created at the same time a user does, but the
> > profiles_users table stays always empty...
> > How do i connect both models in this table via dataset? What i have to
> > do that the relations table get filled automatically with the ids of
> > user and its profile?
>
> A join table is not necessary for hasOne. The association is made
> using a foreign_key in one of the tables. In your case, there should
> be a user_id column in the profiles table.

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: