Representing versions of objects with CakePHP

Posted by user636901 on Stack Overflow See other posts from Stack Overflow or by user636901
Published on 2011-02-27T22:24:33Z Indexed on 2011/02/27 23:24 UTC
Read the original article Hit count: 161

Filed under:
|
|
|

Hi people,

Have just started to get into CakePHP since a couple of weeks back. I have some experience with MVC-frameworks, but this problem holds me back a bit.

I am currently working on a model foo, containing a primary id and some attributes. Since a complete history of the changes of foo is necessary, the content of foo is saved in the table foo_content. The two tables are connected through foo_content.foo_id = foo.id, in Cake with a foo hasMany foo_content-relationship.

To track the versions of foo, foo_content also contains the column version, and foo itself the field currentVersion. The version is an number incremented by one everytime the user updates foo. This is an older native PHP-app btw, to be rewritten on top of Cake. 9 times out of 10 in the app, the most recent version (foo.currentVersion) is the db-entry that need to be represented in the frontend.

My question is simply: is there someway of representing this directly in the model? Or does this kind of logic simply need to be defined in the controller?

Most grateful for your help!

© Stack Overflow or respective owner

Related posts about php

Related posts about mvc