Chris, I would suggest keeping the data in the same single table Books
with a flag that identifies it is a temp record.
The way I do this is I create a field called temp_id by default this
field is NULL. When a user modifies a record you set the original id
into the temp_id and unset the original id:
$this->data['Book']['temp_id'] = $this->data['Book']['id'];
unset($this->data['Book']['id']);
$this->Book->save($this->data);
That creates a new temporary record in the books table where temp_id
refers to the original record.
For the normal index etc I set a
'conditions'=>array('temp_id'=>'null') this way the normal users do
not see the unapproved changes.
The admin view can then use the same model view to see both records
side by side to review what has changed. If the admin approves then
you read from the tempBook record and update the originalBook record
which reverse the changes above and save to the original record. After
the save is done you delete the record with the temp_id.
Load the data as in:
$originalBook = $this->FindByID($id);
$tempBook = $this->FindByTemp_id($id);
In a couple of my models I also have a temp_version which increments
so that I may have multiple changes from the original record. The
admin view becomes a little more complicated but is still a matter of
setting the data using the one model.
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