src/Db/Schema.php
public function insert($table, $columns, $connection = null)
    {
        $command = $this->db->createCommand()->insert($table, $columns);
        if (isset($connection)) {
            $command->setConnection($connection);
        }
        return $command->execute()->then(
            function() use ($table, $columns) {
                $tableSchema = $this->getTableSchema($table);
                $result = [];
                foreach ($tableSchema->primaryKey as $name) {
                    if ($tableSchema->columns[$name]->autoIncrement) {
                        $result[$name] = $this->getLastInsertID($tableSchema->sequenceName);
                        break;
                    }

                    $result[$name] = isset($columns[$name]) ? $columns[$name] : $tableSchema->columns[$name]->defaultValue;
                }

                return $result;
            }
        );
    }
public function insert($table, $columns, $connection = null)
    {
        $command = $this->db->createCommand()->insert($table, $columns);
        if (isset($connection)) {
            $command->setConnection($connection);
        }
        return $command->execute()->then(
            function() use ($table, $columns) {
                $tableSchema = $this->getTableSchema($table);
                $result = [];
                foreach ($tableSchema->primaryKey as $name) {
                    if ($tableSchema->columns[$name]->autoIncrement) {
                        $result[$name] = $this->getLastInsertID($tableSchema->sequenceName);
                        break;
                    }

                    $result[$name] = isset($columns[$name]) ? $columns[$name] : $tableSchema->columns[$name]->defaultValue;
                }

                return $result;
            }
        );
    }
Executes the INSERT command, returning primary key values.
@param string                   $table the table that new rows will be inserted into.
@param array                    $columns the column data (name => value) to be inserted into the table.
@param ConnectionInterface|null $connection
@return ExtendedPromiseInterface with array|false primary key values or false if the command fails