public function insertBatchFiles(string $tableName, $fileNames, array $columns = [], string $format = 'CSV')
    {
        if (is_string($fileNames)) {
            $fileNames = [$fileNames];
        }
        if ($this->getCountPendingQueue() > 0) {
            throw new QueryException('Queue must be empty, before insertBatch, need executeAsync');
        }

        if (! in_array($format, self::SUPPORTED_FORMATS, true)) {
            throw new QueryException('Format not support in insertBatchFiles');
        }

        $result = [];

        foreach ($fileNames as $fileName) {
            if (! is_file($fileName) || ! is_readable($fileName)) {
                throw  new QueryException('Cant read file: ' . $fileName . ' ' . (is_file($fileName) ? '' : ' is not file'));
            }

            if (empty($columns)) {
                $sql = 'INSERT INTO ' . $tableName . ' FORMAT ' . $format;
            } else {
                $sql = 'INSERT INTO ' . $tableName . ' ( ' . implode(',', $columns) . ' ) FORMAT ' . $format;
            }
            $result[$fileName] = $this->transport()->writeAsyncCSV($sql, $fileName);
        }

        // exec
        $this->executeAsync();

        // fetch resutl
        foreach ($fileNames as $fileName) {
            if (! $result[$fileName]->isError()) {
                continue;
            }

            $result[$fileName]->error();
        }

        return $result;
    }
public function insertBatchFiles(string $tableName, $fileNames, array $columns = [], string $format = 'CSV')
    {
        if (is_string($fileNames)) {
            $fileNames = [$fileNames];
        }
        if ($this->getCountPendingQueue() > 0) {
            throw new QueryException('Queue must be empty, before insertBatch, need executeAsync');
        }

        if (! in_array($format, self::SUPPORTED_FORMATS, true)) {
            throw new QueryException('Format not support in insertBatchFiles');
        }

        $result = [];

        foreach ($fileNames as $fileName) {
            if (! is_file($fileName) || ! is_readable($fileName)) {
                throw  new QueryException('Cant read file: ' . $fileName . ' ' . (is_file($fileName) ? '' : ' is not file'));
            }

            if (empty($columns)) {
                $sql = 'INSERT INTO ' . $tableName . ' FORMAT ' . $format;
            } else {
                $sql = 'INSERT INTO ' . $tableName . ' ( ' . implode(',', $columns) . ' ) FORMAT ' . $format;
            }
            $result[$fileName] = $this->transport()->writeAsyncCSV($sql, $fileName);
        }

        // exec
        $this->executeAsync();

        // fetch resutl
        foreach ($fileNames as $fileName) {
            if (! $result[$fileName]->isError()) {
                continue;
            }

            $result[$fileName]->error();
        }

        return $result;
    }
public function insertBatchFiles ( string $ tableName , $ fileNames , array $ columns = [ ] , string $ format = 'CSV' ) { if ( is_string ( $ fileNames ) ) { $ fileNames = [ $ fileNames ] ; } if ( $ this -> getCountPendingQueue ( ) > 0 ) { throw new QueryException ( 'Queue must be empty, before insertBatch, need executeAsync' ) ; } if ( ! in_array ( $ format , self :: SUPPORTED_FORMATS , true ) ) { throw new QueryException ( 'Format not support in insertBatchFiles' ) ; } $ result = [ ] ; foreach ( $ fileNames as $ fileName ) { if ( ! is_file ( $ fileName ) || ! is_readable ( $ fileName ) ) { throw new QueryException ( 'Cant read file: ' . $ fileName . ' ' . ( is_file ( $ fileName ) ? '' : ' is not file' ) ) ; } if ( empty ( $ columns ) ) { $ sql = 'INSERT INTO ' . $ tableName . ' FORMAT ' . $ format ; } else { $ sql = 'INSERT INTO ' . $ tableName . ' ( ' . implode ( ',' , $ columns ) . ' ) FORMAT ' . $ format ; } $ result [ $ fileName ] = $ this -> transport ( ) -> writeAsyncCSV ( $ sql , $ fileName ) ; } // exec $ this -> executeAsync ( ) ; // fetch resutl foreach ( $ fileNames as $ fileName ) { if ( ! $ result [ $ fileName ] -> isError ( ) ) { continue ; } $ result [ $ fileName ] -> error ( ) ; } return $ result ; }
insert Batch Files

@param string|string[] $fileNames
@param string[]        $columns
@param string          $format ['TabSeparated','TabSeparatedWithNames','CSV','CSVWithNames']
@return Statement[]
@throws Exception\TransportException
insert Batch Files