src/models/Schema.php
public function getTableData(TableSchema $table, $limit = null, $indent = 0)
    {

        if (null === $limit) {
            return '';
        }

        $data = [];
        $_limit = '';
        $batchInsertLength = 500;
        $textIndent = $this->textIndent($indent);
        $definition = $textIndent . '$this->_transaction = $this->getDb()->beginTransaction();' . self::ENTER;

        if (is_bool($limit)) { // -limit
            $_limit = [null, null]; // select all data
        } elseif (empty($limit)) { // -limit=
            $_limit = [null, null]; // select all data
        } elseif (false !== strpos($limit, ',')) { // -limit=1,10 or -limit=1,
            $_limit = explode(',', $limit);

            if (empty($_limit[1])) { // -limit=1,
                $_limit[1] = null;
            }
        } else { // -limit=1
            $_limit[0] = 0;
            $_limit[1] = $limit;
        }

        $limitCount = $_limit[1] - $_limit[0];

        $tableName = static::removePrefix($table->name, $this->db->tablePrefix);

        $tableColumns = $table->columns;

        // 获取字段名称
        $columns = $this->textIndent($indent + 1) . '[';
        foreach ($tableColumns as $value) {
            $columns .= "'{$value->name}', ";
        }
        $columns = rtrim($columns, ', ') . ']';

        $query = (new Query())
            ->select('*')
            ->from($table->name)
            ->offset($_limit[0])
            ->limit($_limit[1])
        ;

        if ($limitCount > $batchInsertLength) {
            // 批量查询
            foreach ($query->batch($batchInsertLength, $this->db) as $rows) {
                $data = array_merge($data, $rows);
            }

            if (empty($data)) {
                return '';
            }

            $countData = count($data);
            for ($i = 0; $i < $countData; $i += $batchInsertLength) {
                $insertData = $this->twoArrayStyleString(array_slice($data, $i, $batchInsertLength), $tableColumns, $indent + 1);

                // $this->batchInsert({{%tableName}},
                //     [$columns],
                //     [$insertData]
                // );
                $definition .= $textIndent;
                $definition .= "\$this->batchInsert('{{%$tableName}}', " . self::ENTER;
                $definition .= $columns . ',' . self::ENTER;
                $definition .= $insertData . self::ENTER;
                $definition .= $textIndent . ');' . self::ENTER;
            }

        } else {
            $data = $query->all($this->db);

            if (empty($data)) {
                return '';
            }

            $insertData = $this->twoArrayStyleString($data, $tableColumns, $indent + 1);

            // $this->batchInsert({{%tableName}},
            //     [$columns],
            //     [$insertData]
            // );
            $definition .= $textIndent;
            $definition .= "\$this->batchInsert('{{%$tableName}}', " . self::ENTER;
            $definition .= $columns . ',' . self::ENTER;
            $definition .= $insertData . self::ENTER;
            $definition .= $textIndent . ');' . self::ENTER;
        }

        $definition .= $textIndent . '$this->_transaction->commit();' . self::ENTER;

        return $definition;

    }
public function getTableData(TableSchema $table, $limit = null, $indent = 0)
    {

        if (null === $limit) {
            return '';
        }

        $data = [];
        $_limit = '';
        $batchInsertLength = 500;
        $textIndent = $this->textIndent($indent);
        $definition = $textIndent . '$this->_transaction = $this->getDb()->beginTransaction();' . self::ENTER;

        if (is_bool($limit)) { // -limit
            $_limit = [null, null]; // select all data
        } elseif (empty($limit)) { // -limit=
            $_limit = [null, null]; // select all data
        } elseif (false !== strpos($limit, ',')) { // -limit=1,10 or -limit=1,
            $_limit = explode(',', $limit);

            if (empty($_limit[1])) { // -limit=1,
                $_limit[1] = null;
            }
        } else { // -limit=1
            $_limit[0] = 0;
            $_limit[1] = $limit;
        }

        $limitCount = $_limit[1] - $_limit[0];

        $tableName = static::removePrefix($table->name, $this->db->tablePrefix);

        $tableColumns = $table->columns;

        // 获取字段名称
        $columns = $this->textIndent($indent + 1) . '[';
        foreach ($tableColumns as $value) {
            $columns .= "'{$value->name}', ";
        }
        $columns = rtrim($columns, ', ') . ']';

        $query = (new Query())
            ->select('*')
            ->from($table->name)
            ->offset($_limit[0])
            ->limit($_limit[1])
        ;

        if ($limitCount > $batchInsertLength) {
            // 批量查询
            foreach ($query->batch($batchInsertLength, $this->db) as $rows) {
                $data = array_merge($data, $rows);
            }

            if (empty($data)) {
                return '';
            }

            $countData = count($data);
            for ($i = 0; $i < $countData; $i += $batchInsertLength) {
                $insertData = $this->twoArrayStyleString(array_slice($data, $i, $batchInsertLength), $tableColumns, $indent + 1);

                // $this->batchInsert({{%tableName}},
                //     [$columns],
                //     [$insertData]
                // );
                $definition .= $textIndent;
                $definition .= "\$this->batchInsert('{{%$tableName}}', " . self::ENTER;
                $definition .= $columns . ',' . self::ENTER;
                $definition .= $insertData . self::ENTER;
                $definition .= $textIndent . ');' . self::ENTER;
            }

        } else {
            $data = $query->all($this->db);

            if (empty($data)) {
                return '';
            }

            $insertData = $this->twoArrayStyleString($data, $tableColumns, $indent + 1);

            // $this->batchInsert({{%tableName}},
            //     [$columns],
            //     [$insertData]
            // );
            $definition .= $textIndent;
            $definition .= "\$this->batchInsert('{{%$tableName}}', " . self::ENTER;
            $definition .= $columns . ',' . self::ENTER;
            $definition .= $insertData . self::ENTER;
            $definition .= $textIndent . ');' . self::ENTER;
        }

        $definition .= $textIndent . '$this->_transaction->commit();' . self::ENTER;

        return $definition;

    }
fetch table data limit(start,end)
@param TableSchema $table
@param $limit string select data from table limit ...
@param $indent int text-indent 文本缩进
@return string