public function beginChangeset()
    {
        /** @var ActiveRecord $model */
        $model = $this->owner;
        $id = $model->getDb()->getSchema()->insert($this->changesetTableName, [
            'transaction_id' => new Expression('txid_current()'),
            'user_id'        => Yii::$app->user->getId(),
            'session_id'     => Yii::$app->has('session') ? Yii::$app->session->getId() : null,
            'request_date'   => date('Y-m-d H:i:s'),
            'request_url'    => Yii::$app->request instanceof \yii\web\Request ? Yii::$app->request->getUrl() : null,
            'request_addr'   => Yii::$app->request instanceof \yii\web\Request ? Yii::$app->request->getUserIP() : null,
        ]);
        $model->getDb()->createCommand('SET LOCAL audit.changeset_id = ' . reset($id))->execute();
    }
public function beginChangeset()
    {
        /** @var ActiveRecord $model */
        $model = $this->owner;
        $id = $model->getDb()->getSchema()->insert($this->changesetTableName, [
            'transaction_id' => new Expression('txid_current()'),
            'user_id'        => Yii::$app->user->getId(),
            'session_id'     => Yii::$app->has('session') ? Yii::$app->session->getId() : null,
            'request_date'   => date('Y-m-d H:i:s'),
            'request_url'    => Yii::$app->request instanceof \yii\web\Request ? Yii::$app->request->getUrl() : null,
            'request_addr'   => Yii::$app->request instanceof \yii\web\Request ? Yii::$app->request->getUserIP() : null,
        ]);
        $model->getDb()->createCommand('SET LOCAL audit.changeset_id = ' . reset($id))->execute();
    }
public function beginChangeset ( ) { /** @var ActiveRecord $model */ $ model = $ this -> owner ; $ id = $ model -> getDb ( ) -> getSchema ( ) -> insert ( $ this -> changesetTableName , [ 'transaction_id' => new Expression ( 'txid_current()' ) , 'user_id' => Yii :: $ app -> user -> getId ( ) , 'session_id' => Yii :: $ app -> has ( 'session' ) ? Yii :: $ app -> session -> getId ( ) : null , 'request_date' => date ( 'Y-m-d H:i:s' ) , 'request_url' => Yii :: $ app -> request instanceof \ yii \ web \ Request ? Yii :: $ app -> request -> getUrl ( ) : null , 'request_addr' => Yii :: $ app -> request instanceof \ yii \ web \ Request ? Yii :: $ app -> request -> getUserIP ( ) : null , ] ) ; $ model -> getDb ( ) -> createCommand ( 'SET LOCAL audit.changeset_id = ' . reset ( $ id ) ) -> execute ( ) ; }
Creates a new db audit changeset, which contains metadata
like current user id, request url and client ip address.
@throws \yii\db\Exception
Creates a new db audit changeset which contains metadata like current user id request url and client ip address .