开发者

Implementing a rollback system

I have a site which allows users to make changes to content. How can I implement a rollback system? I'm using php and mysql, I was thinking of creating tables such as the following:

posts table --- posts_rollback table --- rollback table

The posts_rollback table would act as a lookup table. The posts table has a one to many relat开发者_Python百科ionship with the posts_rollback table. I would then use inner_join to

Is there a better way of doing this or any class/feature which automatically does this itself?


I think what you mean is content versioning (like here on SO) rather than rollbacks - the term "rollback" is mostly used in context of database transactions.

The simplest thing that comes to mind is to have two tables: posts that stores non-editable data (author, date created) and content with versioned data (text, date-updated, editor etc). Have a field called "version" in the posts table. When a post is updated, increase "version" and insert the data into content, along with post ID and "version". When retrieving posts, join content with posts on posts.id and posts.version.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜