Hi guys,

Hopefully a fairly straight forward question. I have the following two
models: Member, User. User hasOne Member, Member belongsTo User.

In my application, I have a Members admin area, which lists all the
Members. I need to allow the admin to create a corresponding User for
a Member and so have created a method in my Members model as follows.

function createUser()
{

        $data = array();

        $data['username'] = str_replace("/", "", $this->field('member_num'));
        $data['password'] = 'password';

        $this->User->create($data);
        $this->User->saveAll();
}

This works as far as creating the new user, setting the password and
the username but doesn't establish the relationship between the user
and member. In my member table, I have a user_id column, but this is
not populated. I understand why, to some extent but am not sure how to
go about fixing this.

Could anyone suggest what needs to be done to create the relationship
between these two models?

Many thanks,

Alastair
--~--~---------~--~----~------------~-------~--~----~
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