mirror of
https://github.com/friendica/friendica
synced 2024-11-18 23:03:40 +00:00
Add parameter for "toArray()" method
This commit is contained in:
parent
8f130335a3
commit
4a3544582c
2 changed files with 10 additions and 3 deletions
|
@ -129,9 +129,16 @@ abstract class BaseModel
|
|||
$this->data[$name] = $value;
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
/**
|
||||
* Returns the values of the current model as an array
|
||||
*
|
||||
* @param bool $dbOnly True, if just the db-relevant fields should be returned
|
||||
*
|
||||
* @return array The values of the current model
|
||||
*/
|
||||
public function toArray(bool $dbOnly = false)
|
||||
{
|
||||
return $this->mapFields($this->data);
|
||||
return $dbOnly ? $this->mapFields($this->data) : $this->data;
|
||||
}
|
||||
|
||||
protected function checkValid()
|
||||
|
|
|
@ -122,7 +122,7 @@ abstract class BaseRepository extends BaseFactory
|
|||
*/
|
||||
public function update(BaseModel $model)
|
||||
{
|
||||
if ($this->dba->update(static::$table_name, $model->toArray(), ['id' => $model->id], $model->getOriginalData())) {
|
||||
if ($this->dba->update(static::$table_name, $model->toArray(true), ['id' => $model->id], $model->getOriginalData())) {
|
||||
$model->resetOriginalData();
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue