public function run()
 {
     $m = new AuditTrail();
     $m->unsetAttributes();
     $m->model = get_class($this->model);
     $m->model_id = $this->model->getPrimaryKey();
     $this->renderpartial('history', array('model' => $m, 'id' => $this->id));
 }
Example #2
0
 /**
  *
  * @param model $model
  */
 protected function _getWherePrimaryKeySql($model, $useAssignedValues = false)
 {
     $wherea = array();
     $pk = $model->getPrimaryKey();
     if (count($pk)) {
         foreach ($pk as $propertyName) {
             $property = $model->{$propertyName};
             $fieldName = $property->getFieldName();
             if (is_object($property)) {
                 $initialValue = $property->getInitialValue();
                 if ($initialValue !== null) {
                     $wherea[] = "`{$fieldName}` = " . $this->quote($initialValue);
                 } else {
                     if ($useAssignedValues) {
                         $value = $property->getInternalValue();
                         if ($value !== null) {
                             $wherea[] = "`{$fieldName}` = " . $this->quote($value);
                         }
                     }
                 }
             }
         }
         if (count($pk) == count($wherea)) {
             return " WHERE " . implode(" AND ", $wherea);
         }
     }
     return false;
 }