public function insert($table, $columns)
{
echo " > insert into {$table} ...";
$time = microtime(true);
$this->db->createCommand()->insert($table, $columns)->execute();
echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
}
/** * @inheritdoc */ public function insert($table, $columns) { if ($table != '{{%auth_item}}' || !isset($columns['name'])) { return parent::insert($table, $columns); } $item = (new \yii\db\Query())->from($table)->where(['name' => $columns['name']])->exists(); if (!$item) { return parent::insert($table, $columns); } }