yii\db\Command::insert PHP Method

insert() public method

For example, php $connection->createCommand()->insert('user', [ 'name' => 'Sam', 'age' => 30, ])->execute(); The method will properly escape the column names, and bind the values to be inserted. Note that the created command is not executed until Command::execute is called.
public insert ( string $table, array $columns )
$table string the table that new rows will be inserted into.
$columns array the column data (name => value) to be inserted into the table.
    public function insert($table, $columns)
    {
        $params = [];
        $sql = $this->db->getQueryBuilder()->insert($table, $columns, $params);
        return $this->setSql($sql)->bindValues($params);
    }