I have a User hasMany Post and a Post belongs to User. The function to
add a post with an user id is inserting a user with null email and
null password into the users table and a post with an user id
increased by one into the posts table. Take a look...
function add() {
if (!empty ($this->data)) {
$usersaved = $this->User->save($this->data);
$this->data['Post']['user_id'] = $this->User->id;
$postsaved = $this->User->Post->save($this->data);
if($postsaved && $usersaved) {
$this->flash('The post has been saved.', '/posts');
}
}
}
How to solve this problem?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---