TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Tracking Object Changes
  • Greetings,

    I have few models (Student, HealthInsurance, Answer) in my application for which I need to keep track of latest changes. I'm relying on ORM's '_changed' property to determine the changes made to the object and then I simply serialize the information and save it to my 'changes' table. The only exception is the 'Answer' model, because the 'Student' can have many 'Answers' to a quiz and I can't rely on '_changed' property. Initially, I overwrote ORM's update() function to handle 'Student' and 'Answer' and I placed in the 'Abstract' model. In the update() function I included the exception for 'Answer' model, but don't know if that is the best way to do it (adding functionality to Abstract model to handle Answer model changes?). Should I maybe implement an interface (let's call it Trackable) and make sure the Student, HealthInsurance and Answer implement Trackable interface?

    Any thoughts would be greatly appreciated.

    Thanks, Z

  • I use a little module I wrote for this purpose: http://kohana-modules.com/modules/samwilson/kohana_datalog

    Basically, it saves each modification (both old and new values) in a row in a datalog table, and also uses candidate keys of related tables (rather than their primary keys) so that it can be completely safe with future schema modifications (and still make sense).

    Couldn't you handle the changes to Answers in their own right, separately from the changes to Student? Or do you want them to appear as actually being changes to Student? (i.e. the log entry for Student might say "added Answer 'blah blah'", rather than there being another log entry for the Answer saying "student x said 'blah blah'".)

  • Thanks Sam!

  • @zoltalar maybe try a different approach with activity streams (think of facebook news feed) http://activitystrea.ms/ and also search on this forum about it

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion