fix update query

This commit is contained in:
Dennis Eichhorn 2023-09-27 18:16:48 +00:00
parent ee9391fd97
commit e07798e3b6
3 changed files with 6 additions and 15 deletions

View File

@ -1027,7 +1027,7 @@ class Builder extends BuilderAbstract
/**
* Update columns.
*
* @param mixed ...$columns Column names to update
* @param string $table Column names to update
*
* @return Builder
*
@ -1036,23 +1036,14 @@ class Builder extends BuilderAbstract
*
* @since 1.0.0
*/
public function update(mixed ...$columns) : self
public function update(string $table) : self
{
if ($this->isReadOnly) {
throw new \Exception();
}
$this->type = QueryType::UPDATE;
/** @var mixed[] $columns */
/** @var mixed $table */
foreach ($columns as $column) {
if (\is_string($column) || $column instanceof self) {
$this->updates[] = $column;
} else {
throw new \InvalidArgumentException();
}
}
$this->type = QueryType::UPDATE;
$this->updates[] = $table;
return $this;
}

View File

@ -166,7 +166,7 @@ class CsvDatabaseMapper implements IODatabaseMapper
// update data
while (($cells = \fgetcsv($fp)) !== false) {
$query = new Builder($this->con);
$query->update(...$titles)->into($table);
$query->update($table);
for ($j = 2; $j <= $columns; ++$j) {
$query->sets((string) $titles[$j - 2], $cells[$j - 1]);

View File

@ -221,7 +221,7 @@ class SpreadsheetDatabaseMapper implements IODatabaseMapper
$line = 2;
while (!empty($workSheet->getCell('A' . $line)->getCalculatedValue())) {
$query = new Builder($this->con);
$query->update(...$titles)->into($table);
$query->update($table);
for ($j = 2; $j <= $columns; ++$j) {
$query->sets((string) $titles[$j - 2], $workSheet->getCell(StringUtils::intToAlphabet($j) . $line)->getCalculatedValue());