Don't forget, if you're database does not support transactions you
should make sure you validate the data before you saveAll, or ensure
that any failure to save is handled properly.

Toby

On Nov 16, 5:26 am, Amit Badkas <[email protected]> wrote:
> Hi,
>
> First of all you need to set User's relation with Email. From the DB schema
> you provided, I think it should be User hasOne Email. The view should be
> something like
>
> echo $form->create('User');
> echo $form->input('name');
> echo $form->input('Email.email');
> echo $form->end('Submit');
>
> and the code in action method to save it will be like
>
> $this->User->saveAll($this->data);
>
> Hope this helps.
>
> Amit Badkas
>
> PHP Applications for E-Biz:http://www.sanisoft.com
>
> On Tue, Nov 16, 2010 at 9:54 AM, Rey Philip <[email protected]>wrote:
>
>
>
>
>
>
>
> > I a newbie question. This is how can I save data in many tables. Heres
> > a scenario, example I have a Profiles controller, then I have a
> > register method/action. Lets say I have 2 tables involved the users
> > table and emails table, this is only for the sake of the
> > demonstration. In my view in the register method there are two input
> > boxes name which resides in the users table and email textbox for the
> > emails table. Now what I want to do is that, when I press the submit
> > button I want the name to be saved in the names table and the email to
> > the emails table..
>
> > Here is the schema:
>
> > users table:
> > id
> > name
>
> > emails table:
> > id
> > user_id
> > email
>
> > I wonder what the view for register method would look like, since the
> > form->create() methods 1st paramter is the name of the model.. And
> > also how do I saved the data on two different tables.
>
> > Again, thanks in advance.
>
> > Philip
>
> > 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 [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<cake-php%[email protected] 
> > om>For more options, visit this group at
> >http://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 [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

Reply via email to