src/Db/Command.php
public function insertAndReturn($table, $columns) {
        $params = [];
        $sql = $this->db->getQueryBuilder()->insert($table, $columns, $params);
        $tableSchema = $this->db->getSchema()->getTableSchema($table);
        $returnColumns = $tableSchema->getColumnNames();
        if (!empty($returnColumns)) {
            $returning = [];
            foreach ((array)$returnColumns as $name) {
                $returning[] = $this->db->quoteColumnName($name);
            }
            $sql .= ' RETURNING ' . implode(', ', $returning);
        }

        return $this->setSql($sql)->bindValues($params);
    }
public function insertAndReturn($table, $columns) {
        $params = [];
        $sql = $this->db->getQueryBuilder()->insert($table, $columns, $params);
        $tableSchema = $this->db->getSchema()->getTableSchema($table);
        $returnColumns = $tableSchema->getColumnNames();
        if (!empty($returnColumns)) {
            $returning = [];
            foreach ((array)$returnColumns as $name) {
                $returning[] = $this->db->quoteColumnName($name);
            }
            $sql .= ' RETURNING ' . implode(', ', $returning);
        }

        return $this->setSql($sql)->bindValues($params);
    }
Creates an INSERT command with RETURNING statement.

For example,

```php
$connection->createCommand()->insertAndReturn('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 [[execute()]] is called.

@param string $table the table that new rows will be inserted into.
@param array|\Reaction\Db\Query $columns the column data (name => value) to be inserted into the table or instance
of [[Reaction\Db\Query|Query]] to perform INSERT INTO ... SELECT SQL statement.
@return $this the command object itself