Monday, October 3, 2011

Re: history log table

you could write a method in the model or even a behavior which will do
that for you
in the beforeSave() callback it can be triggered globally


On 3 Okt., 06:38, elogic <asymo...@elogicmedia.com.au> wrote:
> My client wants a listing of all actions that happen within the system
> so they can check back and search the records at a later date.
>
> I thought the best way to handle this would be to have a histories
> table which would be similar to below:
>
> CREATE TABLE `histories` (
>         `id` INT(11) NULL AUTO_INCREMENT,
>         `user_id` INT(11) NOT NULL DEFAULT '0',
>         `action` VARCHAR(50) NULL DEFAULT NULL,
>         `content` VARCHAR(250) NULL DEFAULT NULL,
>         `created` DATETIME NULL DEFAULT NULL,
>         `modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
> CURRENT_TIMESTAMP,
>         PRIMARY KEY (`id`),
>         INDEX `user_id` (`user_id`)
> )
>
> How would I go about inserting the user_id (the logged user - using
> Auth), action (i.e. create, edit, delete, login etc) and content
> (added joe blogs or deleted record ID123 etc) from every section
> within the site?
>
> Thanks

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: