2023-09-12
This commit is contained in:
@ -112,14 +112,15 @@ abstract class Repository implements Define\Repository
|
||||
$values []= $data[$column];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($changes) === 0) {
|
||||
return $model;
|
||||
}
|
||||
$columns_string = implode(', ', array_map(function($property) {return "`{$property}` = ?";}, $changes));
|
||||
$query = "UPDATE `{$this->getTable()}` SET {$columns_string} WHERE `{$this->getKey()}` = ?";
|
||||
$values []= $model->id;
|
||||
$values []= $model->{$this->getKey()};
|
||||
$this->connection->execute($query, $values);
|
||||
return $this->fetchById($model->id);
|
||||
return $this->fetchById($model->{$this->getKey()});
|
||||
}
|
||||
protected function fetchOne(string $query, ?array $data = null): Define\Model
|
||||
{
|
||||
|
Reference in New Issue
Block a user