Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Commit

Permalink
more code
Browse files Browse the repository at this point in the history
  • Loading branch information
bupy7 committed Jan 3, 2016
1 parent 9a1cf41 commit 145e9d0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
30 changes: 15 additions & 15 deletions behaviors/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,22 @@ public function saveHistory(Event $event)
switch ($event->name) {
case BaseActiveRecord::EVENT_AFTER_INSERT:
$model = new HistoryEntity([
'table_name' => $tableName,
'row_id' => $rowId,
'tableName' => $tableName,
'rowId' => $rowId,
'event' => HistoryEntity::EVENT_INSERT,
'created_at' => $createdAt,
'created_by' => $createdBy,
'createdAt' => $createdAt,
'createdBy' => $createdBy,
]);
$storage->add($model);
break;

case BaseActiveRecord::EVENT_AFTER_DELETE:
$model = new HistoryEntity([
'table_name' => $tableName,
'row_id' => $rowId,
'tableName' => $tableName,
'rowId' => $rowId,
'event' => HistoryEntity::EVENT_DELETE,
'created_at' => $createdAt,
'created_by' => $createdBy,
'createdAt' => $createdAt,
'createdBy' => $createdBy,
]);
$storage->add($model);
break;
Expand All @@ -119,14 +119,14 @@ public function saveHistory(Event $event)
continue;
}
$model = new HistoryEntity([
'table_name' => $tableName,
'row_id' => $rowId,
'field_name' => $name,
'old_value' => $value,
'new_value' => $this->owner->$name,
'tableName' => $tableName,
'rowId' => $rowId,
'fieldName' => $name,
'oldValue' => $value,
'newValue' => $this->owner->$name,
'event' => HistoryEntity::EVENT_UPDATE,
'created_at' => $createdAt,
'created_by' => $createdBy,
'createdAt' => $createdAt,
'createdBy' => $createdBy,
]);
$storage->add($model);
}
Expand Down
14 changes: 7 additions & 7 deletions entities/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,34 @@ class History extends Object
/**
* @var string Name of table where has been created or updated field.
*/
public $table_name;
public $tableName;
/**
* @var integer Id of row where has been created or updated field.
*/
public $row_id;
public $rowId;
/**
* @var string Name change of field.
*/
public $field_name;
public $fieldName;
/**
* @var string Old value of field before updated field.
*/
public $old_value;
public $oldValue;
/**
* @var string New value of field after created or updated field.
*/
public $new_value;
public $newValue;
/**
* @var integer Event type of history to the AR object.
*/
public $event;
/**
* @var integer Timestamp of create or update field.
*/
public $created_at;
public $createdAt;
/**
* @var integer Id of user which created or updated field.
*/
public $created_by;
public $createdBy;
}

14 changes: 7 additions & 7 deletions storages/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ protected function prepareQuery(array $collection)
$params = [];
for ($i = 0; $i != count($collection); $i++) {
$row = [
'table_name' => $collection[$i]->table_name,
'field_name' => $collection[$i]->field_name,
'row_id' => $collection[$i]->row_id,
'old_value' => $collection[$i]->old_value,
'new_value' => $collection[$i]->new_value,
'table_name' => $collection[$i]->tableName,
'field_name' => $collection[$i]->fieldName,
'row_id' => $collection[$i]->rowId,
'old_value' => $collection[$i]->oldValue,
'new_value' => $collection[$i]->newValue,
'event' => $collection[$i]->event,
'created_at' => $collection[$i]->created_at,
'created_by' => $collection[$i]->created_by,
'created_at' => $collection[$i]->createdAt,
'created_by' => $collection[$i]->createdBy,
];
$sql[] = $queryBuilder->insert($this->module->tableName, $row, $params);
}
Expand Down

0 comments on commit 145e9d0

Please sign in to comment.