Think\Db\Query::insert PHP Method

insert() public method

插入记录
public insert ( array $data, boolean $replace = false, boolean $getLastInsID = false, string $sequence = null ) : integer | string
$data array 数据
$replace boolean 是否replace
$getLastInsID boolean 返回自增主键
$sequence string 自增序列名
return integer | string
    public function insert(array $data, $replace = false, $getLastInsID = false, $sequence = null)
    {
        // 分析查询表达式
        $options = $this->parseExpress();
        // 生成SQL语句
        $sql = $this->builder()->insert($data, $options, $replace);
        // 获取参数绑定
        $bind = $this->getBind();
        if ($options['fetch_sql']) {
            // 获取实际执行的SQL语句
            return $this->connection->getRealSql($sql, $bind);
        }
        // 执行操作
        $result = $this->execute($sql, $bind);
        if ($getLastInsID) {
            $sequence = $sequence ?: (isset($options['sequence']) ? $options['sequence'] : null);
            return $this->getLastInsID($sequence);
        }
        return $result;
    }