Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

Commit

Permalink
Fix bug in updateOrCreate
Browse files Browse the repository at this point in the history
  • Loading branch information
mathcals committed Apr 2, 2018
1 parent 338f512 commit e7fdc45
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/PersistenceModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,12 @@ protected function deleteByPrimaryKey(array $primary_key_values) {
* @return boolean whether a new row was created
*/
public function updateOrCreate(PersistentEntity $entity) {
if ($this->update($entity) != 0) {
//Row already exists
return false;
if ($this->exists($entity)) {
$this->update($entity);
return true;
} else {
//Row does not yet exist, we create it
$this->create($entity);
return true;
return false;
}
}

Expand Down

0 comments on commit e7fdc45

Please sign in to comment.