Exemple #1
0
 public function beforeSave($insert)
 {
     if ($insert && $this->hasAttribute('created')) {
         $this->created = new \yii\db\Expression('NOW()');
     }
     if ($this->autoSerialize) {
         foreach ($this->serializeAttributes as $attribute) {
             if ($this->hasAttribute($attribute)) {
                 $this->{$attribute} = Helper::serialize($this->{$attribute}, false);
             }
         }
     }
     return parent::beforeSave($insert);
 }
 /**
  * @param bool $insert
  * @return bool
  */
 public function beforeSave($insert)
 {
     if ($insert && $this->hasAttribute('created')) {
         $this->created = date('Y-m-d H:i:s');
     }
     if ($this->autoSerialize) {
         foreach ($this->serializeAttributes as $attribute) {
             if ($this->hasAttribute($attribute)) {
                 $this->{$attribute} = [Helper::serialize($this->{$attribute}, false), \PDO::PARAM_LOB];
             }
         }
     }
     return parent::beforeSave($insert);
 }
 public function addBatchData($batchData)
 {
     $columns = ['entry_id', 'type', 'data', 'packed'];
     $rows = [];
     foreach ($batchData as $type => $data) {
         $rows[] = [$this->id, $type, Helper::serialize($data), 1];
     }
     Yii::$app->db->createCommand()->batchInsert(AuditData::tableName(), $columns, $rows)->execute();
 }
 public function addData($type, $data, $compact = true)
 {
     $record = ['entry_id' => $this->id, 'type' => $type, 'data' => Helper::serialize($data, $compact)];
     static::getDb()->createCommand()->insert(AuditData::tableName(), $record)->execute();
 }
Exemple #5
0
 /**
  * @param $type
  * @param $data
  * @param bool|true $compact
  * @throws \yii\db\Exception
  */
 public function addData($type, $data, $compact = true)
 {
     // Make sure to mark data as a large object so it gets escaped
     $record = ['entry_id' => $this->id, 'type' => $type, 'data' => [Helper::serialize($data, $compact), \PDO::PARAM_LOB]];
     static::getDb()->createCommand()->insert(AuditData::tableName(), $record)->execute();
 }