Create / Insert / Save from Model

2009-10-05 Thread Dave Maharaj :: WidePixels.com
I have a rather large function during user registration. 
 
Depending on the role they are registering as i create records for that
specific role populating their profile and additional required tables with
id's for the new user.
 
The 2 roles require different tables so i currently have an 
if (role_id = roleOne)
{
build role 1 table set up
 
} else {
build role 2 table set up
 
}
 
I was just wondering if i created 2 functions
buildRole1($id, $data)
{
$this-data['User']['id'] = $this-Profile-id;
create();
$q = getMyOtherInfo();
//fill the data into the profile
save();
and so on
 
}
 
and build Role2($id)
 
{
 
 
 
}
 
can i actually create new records from the model and save them? Or should it
be kept in the controller?
 
Dave Maharaj
Freelance Designer
d...@widepixels.com
www.widepixels.com
 

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Create / Insert / Save from Model

2009-10-05 Thread Miles J

Of course you can do it from the Model. It doesn't matter where that
logic is placed.

On Oct 5, 8:51 am, Dave Maharaj :: WidePixels.com
d...@widepixels.com wrote:
 I have a rather large function during user registration.

 Depending on the role they are registering as i create records for that
 specific role populating their profile and additional required tables with
 id's for the new user.

 The 2 roles require different tables so i currently have an
 if (role_id = roleOne)
 {
 build role 1 table set up

 } else {

 build role 2 table set up

 }

 I was just wondering if i created 2 functions
 buildRole1($id, $data)
 {
 $this-data['User']['id'] = $this-Profile-id;
 create();
 $q = getMyOtherInfo();
 //fill the data into the profile
 save();
 and so on

 }

 and build Role2($id)

 {

 }

 can i actually create new records from the model and save them? Or should it
 be kept in the controller?

 Dave Maharaj
 Freelance Designer
 d...@widepixels.comwww.widepixels.com
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---