This topic is locked

Record History feature?

8/21/2007 6:03:31 PM
PHPRunner General questions
F
fsteves author

I am curious as to how I would possibly go about adding some sort of History feature, linked to a field called Event, which is populated from a table called table_events, and in that table each Event has an ID.
What happens is, the general data stays the same for the record, but with each event, some fields will get different values. Eventually it will all be used for statistics as to what happened in recent events for a person.

M
morpheus 8/21/2007

I am curious as to how I would possibly go about adding some sort of History feature, linked to a field called Event, which is populated from a table called table_events, and in that table each Event has an ID.

What happens is, the general data stays the same for the record, but with each event, some fields will get different values. Eventually it will all be used for statistics as to what happened in recent events for a person.


what I've done with my database is to have a field called "current" and an autoincrementing field called id, each record also has a fixed identifier (in my case part number) that remains fixed, when you update the record what you actually do is copy the record while setting its "current" value to FALSE, then you make the changes you need to the copied record which has its current value set to TRUE by default. Then just use the simplified queries shown below
to see the history

SELECT from xxxxx where partnumber='whatever'
to see only current records

SELECT
from xxxxx where current='TRUE'
This method works with only one table, no need for linking! it works quite well for the stock system I've developed where each item has a fully trackable history. Hopefully this will make sense, if not then ask away <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=20694&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
regards
Jason

G
gshafer 8/23/2007

Could you add some detail as to the mechanism you use to change this field on an edit.
Thanks.....George