Skip to content

Commit

Permalink
Merge branch 'less-writes' of github.com:staabm/mysqldump-php into 1.…
Browse files Browse the repository at this point in the history
…1.0-features
  • Loading branch information
back-2-95 committed Feb 25, 2024
2 parents 178d8c6 + c003fb9 commit 9165606
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Mysqldump.php
Original file line number Diff line number Diff line change
Expand Up @@ -835,41 +835,41 @@ private function listValues(string $tableName)
$ignore = $this->settings->isEnabled('insert-ignore') ? ' IGNORE' : '';
$count = 0;

$line = '';
foreach ($resultSet as $row) {
$count++;
$values = $this->prepareColumnValues($tableName, $row);
$valueList = implode(',', $values);

if ($onlyOnce || !$this->settings->isEnabled('extended-insert')) {
if ($this->settings->isEnabled('complete-insert') && count($colNames)) {
$lineSize += $this->write(sprintf(
$line .= sprintf(
'INSERT%s INTO `%s` (%s) VALUES (%s)',
$ignore,
$tableName,
implode(', ', $colNames),
$valueList
));
} else {
$lineSize += $this->write(
sprintf('INSERT%s INTO `%s` VALUES (%s)', $ignore, $tableName, $valueList)
);
} else {
$line .= sprintf('INSERT%s INTO `%s` VALUES (%s)', $ignore, $tableName, $valueList);
}
$onlyOnce = false;
} else {
$lineSize += $this->write(sprintf(',(%s)', $valueList));
$line .= sprintf(',(%s)', $valueList);
}

if (($lineSize > $this->settings->getNetBufferLength())
if ((strlen($line) > $this->settings->getNetBufferLength())
|| !$this->settings->isEnabled('extended-insert')) {
$onlyOnce = true;
$lineSize = $this->write(';' . PHP_EOL);
$this->write($line . ';' . PHP_EOL);
$line = '';
}
}

$resultSet->closeCursor();

if (!$onlyOnce) {
$this->write(';' . PHP_EOL);
if ($line !== '') {
$this->write($line. ';' . PHP_EOL);
}

$this->endListValues($tableName, $count);
Expand Down

0 comments on commit 9165606

Please sign in to comment.