Monday, December 5, 2011

Re: cakephp revisionable behavior

I like the principle, but how does it work in practice? A few questions:

- I haven't looked at the code, but my guess is that you are storing an array?
- You also mention that it stores related data. So does this mean that if a table can be updated from two places - one with a save and the other with a saveAll - that the array it stores in each case is different?
- How do you get the data back out and into the database - or is the purpose something other than rolling back?
- How do you parse the rows to get an understanding of what's happened?
- How do you find the revision you are looking for (say something changed about a week ago and you want to find out what happened and who did it?).
- If you apply this to lots of tables it's going to become huge, isn't it?

Jeremy Burns

On 6 Dec 2011, at 06:5632, anagrithems wrote:

Not sure if anyone else has been looking for this like me, but I
created an easy to use simple versionable behavior for cakephp 1.3  it
hooks into the beforeSave callback and grabs a copy of the data before
it changes and stores it in a revsions table.  The great thing about
this plugin is that you don't need to make a different shadow table
for each model.  All models can be placed into the same table.

I've thrown together a quick article on it in the bakery
http://bakery.cakephp.org/articles/analogrithems/2011/12/06/simple_revisionable_behavior_with_cakephp_1_3

Code is available at https://github.com/analogrithems/revisionable

The install is super simple two steps
1) First you need to add the table to your project use the following
to generate that
cake schema create Revisionable.revision

2) add the behavior to your model like so

var $actAs = array('Revisionable.Revisionable');


I'd love feedback on this if anyone sees fit.

--
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: