like:
$this->User->save($this->data);
$this->User->Site->save(array('Site' => array(
'user_id' => $this->User->id,
// --- any other data
)));
$this->User->Site->SitePage->save(array('SitePage' => array(
'site_id' => $this->User->Site->id,
// --- any other data
)));
Tada!
Associationes from User to Site, and Site to SitePages need to exist for
that to work.
Cheers,
Graham
On Mon, 2 Feb 2009 04:14:48 -0800 (PST), Turgs <timb.php@gmail.com> wrote:
> Hello all
>
> What's an appropriate use of requestAction()?
>
> I have 3 controllers:
> * UsersController
> * SiteController
> * SitePagesController
>
> Within the add() function of UsersController, I want to (a) create a
> new user (b) create a new site for that user with (c) one new page for
> that site.
>
> What's the best way to do this?
>
> I was thinking of:
>
> ######
>
> if ($this->User->save($this->data))
> {
> # create site
> $this->requestAction('/sites/add');
>
> # add a page (homepage) for this site
> $this->requestAction('/sitepages/add');
>
> # Login the user and redirect to the dashboard
> // login code here
> $this->Session->setFlash(SOTF_MSG_USER_WELCOME);
> $this->redirect(array('controller' => 'users' ,'action' =>
> 'dashboard'));
> }
>
> ######
>
> While the code for this looks clean, what I've read seems to indicate
> this isn't such a good idea due to performance issues.
>
> What else would I do?
>
> Thanks
> Turgs
>
--
Cheers,
Graham Weldon
w. http://grahamweldon.com
e. graham@grahamweldon.com
p. +61 407 017 293
--~--~---------~--~----~------------~-------~--~----~
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