mirror of
https://github.com/friendica/friendica
synced 2025-04-21 23:50:18 +00:00
Enable Model lazy updating based on only the changed data
- Simplify update decision in Database
This commit is contained in:
parent
f0474c07ce
commit
559879f41f
3 changed files with 23 additions and 13 deletions
|
@ -122,7 +122,7 @@ abstract class BaseRepository extends BaseFactory
|
|||
*/
|
||||
public function update(BaseModel $model)
|
||||
{
|
||||
return $this->dba->update(static::$table_name, $model->toArray(), ['id' => $model->id], true);
|
||||
return $this->dba->update(static::$table_name, $model->toArray(), ['id' => $model->id], $model->getOriginalData());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,11 +136,13 @@ abstract class BaseRepository extends BaseFactory
|
|||
{
|
||||
$return = $this->dba->insert(static::$table_name, $fields);
|
||||
|
||||
if ($return) {
|
||||
$fields['id'] = $this->dba->lastInsertId();
|
||||
$return = $this->create($fields);
|
||||
if (!$return) {
|
||||
throw new HTTPException\InternalServerErrorException('Unable to insert new row in table "' . static::$table_name . '"');
|
||||
}
|
||||
|
||||
$fields['id'] = $this->dba->lastInsertId();
|
||||
$return = $this->create($fields);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue