title: Detecting changes in the model; php yii framework
body: <p>I'm creating an <strong>audit trail module</strong> that i will put in a larger system; and i've created a table to store the trail entries , as an "auditor" what i want to see the currently logged on user, the page where he/she is in, what action he/she did, and what were the changes and when...</p>
  
  <p>these are basically what i want to see; my audit trail table looks like:</p>
  
  <p><strong>User| Timestamp| Module Name| Action| Old Value| New Value| Description</strong></p>
  
  <p>i basically had no problem getting the user, by </p>
  
  <pre><code>Yii::app()-&gt;session['username'];
  </code></pre>
  
  <p>the page/module and action by getting the controller's :</p>
  
  <pre><code>$this-&gt;module-&gt;getName();
  $this-&gt;action-&gt;id;
  </code></pre>
  
  <p>My problem lies with the changes <strong>old value to new value</strong>, the edits done by the user.
  i could sort of "sniff" out what edits/ changes he/she did by literally copying the variables and passing it through my function where i create the log.. How do i do this dynamically?</p>
  
  <p>i sort of want to detect if a certain model's properties or attributes has been changed and see what changes were made so that i could get a detail log...Thanks ! sorry, i'm really trying hard to explain this. </p>