how to automatically generate other tables?
is there a way get hasOne to automatically generate a entry for me on a table? for instance, i have user hasOne profile, so everytime I create a user i'd like it to create a blank profile entry. Is that possible? Currently my relationship is set like this but it doesn't auto-create for me: class User extends AppModel { var $name = 'User'; var $hasOne = array('Profile' = array( 'className' = 'Profile', 'conditions' = '', 'order' = '', 'dependent' = 'true', 'foreignKey' = 'user_id' ) ); } ? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: how to automatically generate other tables?
easiest way is to in ur users_controller::add action to after you have done User::save, do a $this-User-Profile-save(array('Profile') = array('user_id' = $this-User-id)); I dont know about an automatic way of doing this. A behavior in the after save probably, but you would have to make it. alkemann On 21 Aug, 10:28, rocket [EMAIL PROTECTED] wrote: is there a way get hasOne to automatically generate a entry for me on a table? for instance, i have user hasOne profile, so everytime I create a user i'd like it to create a blank profile entry. Is that possible? Currently my relationship is set like this but it doesn't auto-create for me: class User extends AppModel { var $name = 'User'; var $hasOne = array('Profile' = array( 'className' = 'Profile', 'conditions' = '', 'order' = '', 'dependent' = 'true', 'foreignKey' = 'user_id' ) );} ? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: how to automatically generate other tables?
Yes, it's possible with saveAll()... That being said, why would you want to create a record with no data? On Aug 21, 4:28 am, rocket [EMAIL PROTECTED] wrote: is there a way get hasOne to automatically generate a entry for me on a table? for instance, i have user hasOne profile, so everytime I create a user i'd like it to create a blank profile entry. Is that possible? Currently my relationship is set like this but it doesn't auto-create for me: class User extends AppModel { var $name = 'User'; var $hasOne = array('Profile' = array( 'className' = 'Profile', 'conditions' = '', 'order' = '', 'dependent' = 'true', 'foreignKey' = 'user_id' ) );} ? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: how to automatically generate other tables?
well if my user goes to his profile page, and i execute the Profile- read(), he won't have a profile to access even if it's blank. On Aug 21, 11:06 am, teknoid [EMAIL PROTECTED] wrote: Yes, it's possible with saveAll()... That being said, why would you want to create a record with no data? On Aug 21, 4:28 am, rocket [EMAIL PROTECTED] wrote: is there a way get hasOne to automatically generate a entry for me on a table? for instance, i have user hasOne profile, so everytime I create a user i'd like it to create a blank profile entry. Is that possible? Currently my relationship is set like this but it doesn't auto-create for me: class User extends AppModel { var $name = 'User'; var $hasOne = array('Profile' = array( 'className' = 'Profile', 'conditions' = '', 'order' = '', 'dependent' = 'true', 'foreignKey' = 'user_id' ) );} ? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---