public static function recordEvent($event_type_id, $ticket_id, $old_value, $new_value, $comment) { $resEvent = NULL; $newEvent = new TicketEvents(); //Some validation first if (!isset($event_type_id)) { throw new CException("Event Type required when loggin ticket events."); } if (!isset($ticket_id)) { throw new CException("Ticket ID required when loggin ticket events."); } //Collect and prepare the data $newEvent->event_type_id = $event_type_id; $newEvent->ticket_id = $ticket_id; $newEvent->event_recorded_date = new CDbExpression('NOW()'); $newEvent->old_value = $old_value; $newEvent->new_value = $new_value; $newEvent->comment = $comment; $newEvent->event_performed_by_user_id = User::getCurrentUserId(); //if save susscessfully, just return the new event if ($newEvent->save()) { $resEvent = $newEvent; } return $resEvent; }