fix: return passed value when setting db row value (#16)

Closes #14

From the example in the issue, this can now be fixed like this:
```php
final public DateTimeImmutable $date_created {
			get  => new DateTimeImmutable($this->get(Fields::DATE_CREATED->value));
			set (DateTimeImmutable $date_created) => new DateTimeImmutable(
			  $this->set(Fields::DATE_CREATED->value,
			  $date_created->format(Database::DATETIME_FORMAT)
			));
}
```

Reviewed-on: https://codeberg.org/vlw/scaffold/pulls/16
This commit is contained in:
Victor Westerlund 2025-12-01 13:56:42 +01:00
parent 2f6e24b0a1
commit be03b05191

View file

@ -97,14 +97,16 @@
*
* @param string $key Target column to update
* @param mixed $value New value of target column
* @return bool Update was successful
* @return mixed The value that was sent to $value
*/
public function set(string $key, mixed $value): bool {
public function set(string $key, mixed $value): mixed {
$this->_row[$key] = $value;
return $this->db
$this->db
->from($this->table)
->where($this->where)
->update([$key => $value]);
return $value;
}
}