mirror of
https://codeberg.org/vlw/scaffold.git
synced 2026-01-11 22:16:00 +01:00
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:
parent
2f6e24b0a1
commit
be03b05191
1 changed files with 5 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue