Benchmarking in Yii


enabling SQL:
‘enableProfiling’=>true, // in database setting in config/main.php


Double insert record in Yii2

Hey! do you need that double insert every time user create

public function actionCreate()
$model = new Records();

$model->name = $model->name.’.trustpositifkominfo’;
// second insert here
$clone = new Records;
$clone->attributes = $model->attributes;
$clone->name = ‘*.’.$clone->name;
return $this->redirect([‘view’, ‘id’ => $model->id]);
else {
return $this->render(‘create’, [
‘model’ => $model,


Create customized field value Yii2

hello! After a long hiatus. I got a project for my office. It is a dashboard application for powerdns. All the records  have only 1 master domain. So, I have to do a trick to put trustpositifkominfo as a domain for every record inserted. here is the magic:

public function beforeSave($insert) {

if ($insert) {
$this->domain_id = 1;
$this->name = $this->name.’.trustpositifkominfo’;
return parent::beforeSave($insert);