Results 1 to 1 of 1
Jan 18, 2005, 15:28 #1
- Join Date
- Jan 2005
- Rhode Island
- 0 Post(s)
- 0 Thread(s)
Adding History to a Database accessor class (PHP5)
Long time reader, first time poster. Please forgive me if this post is hard to follow, it is hard for me to explain.
I am currently the sole developer on a PHP5 based project using Propel and Mojavi. This application will track all information (from IP addresses and netgroups to physical location and points-of-contact) related to a host (computer) for the UNIX sysadmin group in my company. This information is saved into a database from which our NIS maps and reports are generated. I am making great progress using the Propel generated DB accessor classes. Which leads me to my question...
I have a requirement to add history for each insert/update/delete to the database. The requirement further states that a history "event" must record the old value as well as the new value for an "object". For example, when updating a NetworkDevice for a Host, the corresponding History "event" should look like this:
Updated Network Device:
Updated IP Address from 192.168.1.100 to 192.168.1.101
Updated Host Name from foo.mycompany.com to bar.mycompany.com
Updated Is Primary from No to Yes
Using the isNew(), isDeleted() and isModified() methods provided by Propel I am able to find the state of an object easily. I can even get a list of the attributes that were modified. How would I go about creating a mechanism for adding a history functionality to each of my DB accessor classes?
I don't want to have to create a method generateHistory() or something like that for each of my 18+ classes. I looked into using a Decorator pattern or Visitor pattern but they both seem to a misuse of my intended application.
Any help is greatly appreciated. If more detail/info is required please let me know. Thanks!