src/Leevel/Database/Condition.php
public function insertAll(array $data, array $bind = [], bool $replace = false): array
    {
        // 绑定参数
        $bind = array_merge($this->getBindParams(), $bind);

        // 构造数据批量插入
        if (is_array($data)) {
            $dataResult = [];
            $questionMark = 0;
            $tableName = $this->getTable();

            foreach ($data as $key => $tmp) {
                if (!is_array($tmp) || count($tmp) !== count($tmp, 1)) {
                    throw new InvalidArgumentException('Data for insertAll is not invalid.');
                }

                list($tmpFields, $values, $bind, $questionMark) = $this->normalizeBindData($tmp, $bind, $questionMark, $key);

                if (0 === $key) {
                    $fields = $tmpFields;

                    foreach ($fields as $fieldKey => $field) {
                        $fields[$fieldKey] = $this->normalizeColumn($field, $tableName);
                    }
                }

                if ($values) {
                    $dataResult[] = '('.implode(',', $values).')';
                }
            }

            // 构造 insertAll 语句
            if ($dataResult) {
                $sql = [];
                $sql[] = ($replace ? 'REPLACE' : 'INSERT').' INTO';
                $sql[] = $this->parseTable();
                $sql[] = '('.implode(',', $fields).')';
                $sql[] = 'VALUES';
                $sql[] = implode(',', $dataResult);
                $data = implode(' ', $sql);

                unset($fields, $values, $sql, $dataResult);
            }
        }

        $bind = array_merge($this->getBindParams(), $bind);

        return [
            $replace ? 'replace' : 'insert',
            $data,
            $bind,
        ];
    }
public function insertAll(array $data, array $bind = [], bool $replace = false): array
    {
        // 绑定参数
        $bind = array_merge($this->getBindParams(), $bind);

        // 构造数据批量插入
        if (is_array($data)) {
            $dataResult = [];
            $questionMark = 0;
            $tableName = $this->getTable();

            foreach ($data as $key => $tmp) {
                if (!is_array($tmp) || count($tmp) !== count($tmp, 1)) {
                    throw new InvalidArgumentException('Data for insertAll is not invalid.');
                }

                list($tmpFields, $values, $bind, $questionMark) = $this->normalizeBindData($tmp, $bind, $questionMark, $key);

                if (0 === $key) {
                    $fields = $tmpFields;

                    foreach ($fields as $fieldKey => $field) {
                        $fields[$fieldKey] = $this->normalizeColumn($field, $tableName);
                    }
                }

                if ($values) {
                    $dataResult[] = '('.implode(',', $values).')';
                }
            }

            // 构造 insertAll 语句
            if ($dataResult) {
                $sql = [];
                $sql[] = ($replace ? 'REPLACE' : 'INSERT').' INTO';
                $sql[] = $this->parseTable();
                $sql[] = '('.implode(',', $fields).')';
                $sql[] = 'VALUES';
                $sql[] = implode(',', $dataResult);
                $data = implode(' ', $sql);

                unset($fields, $values, $sql, $dataResult);
            }
        }

        $bind = array_merge($this->getBindParams(), $bind);

        return [
            $replace ? 'replace' : 'insert',
            $data,
            $bind,
        ];
    }
批量插入数据 insertAll.

@param array $data
@param array $bind
@param bool  $replace

@return array