Hi, I want to update data of several tables when I edit them, but
somehow, it creates new records. :( Does somebody have any idea?
books table [id, name, user_id]
users table [id, name, password]
comments table [id, comment, user_id, book_id]
[books_controller]
var $uses = array('Book','Comment');
function edit($id = null) {
if (!empty($this->data)) {
$this->Book->saveall($this->data);
$this->redirect(array('action' => 'index'));
}
if (empty($this->data)) {
$this->data = $this->Book->read(null, $id);
}
}
[book model]
var $belongsTo = 'User';
var $hasOne = 'Comment';
[index view]
<?php echo $html->link('Edit',array('action' => 'edit', $value['Book']
['id'])); ?>
[edit view]
echo $form->create('Book');
echo $form->input('id');
echo $form->input('Book.name');
echo $form->input('User.name');
echo $form->input('Comment.comment');
echo $form->end('Submit');
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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