/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aUser !== null) { if ($this->aUser->isModified() || $this->aUser->isNew()) { $affectedRows += $this->aUser->save($con); } $this->setUser($this->aUser); } if ($this->aCategory !== null) { if ($this->aCategory->isModified() || $this->aCategory->isNew()) { $affectedRows += $this->aCategory->save($con); } $this->setCategory($this->aCategory); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); $affectedRows += 1; } else { $affectedRows += $this->doUpdate($con); } $this->resetModified(); } if ($this->subNotesScheduledForDeletion !== null) { if (!$this->subNotesScheduledForDeletion->isEmpty()) { \Models\SubNoteQuery::create()->filterByPrimaryKeys($this->subNotesScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->subNotesScheduledForDeletion = null; } } if ($this->collSubNotes !== null) { foreach ($this->collSubNotes as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->filesScheduledForDeletion !== null) { if (!$this->filesScheduledForDeletion->isEmpty()) { \Models\FileQuery::create()->filterByPrimaryKeys($this->filesScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->filesScheduledForDeletion = null; } } if ($this->collFiles !== null) { foreach ($this->collFiles as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->notificationsScheduledForDeletion !== null) { if (!$this->notificationsScheduledForDeletion->isEmpty()) { foreach ($this->notificationsScheduledForDeletion as $notification) { // need to save related object because we set the relation to null $notification->save($con); } $this->notificationsScheduledForDeletion = null; } } if ($this->collNotifications !== null) { foreach ($this->collNotifications as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->commentsScheduledForDeletion !== null) { if (!$this->commentsScheduledForDeletion->isEmpty()) { \Models\CommentQuery::create()->filterByPrimaryKeys($this->commentsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->commentsScheduledForDeletion = null; } } if ($this->collComments !== null) { foreach ($this->collComments as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->sharedsScheduledForDeletion !== null) { if (!$this->sharedsScheduledForDeletion->isEmpty()) { foreach ($this->sharedsScheduledForDeletion as $shared) { // need to save related object because we set the relation to null $shared->save($con); } $this->sharedsScheduledForDeletion = null; } } if ($this->collShareds !== null) { foreach ($this->collShareds as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); $affectedRows += 1; } else { $affectedRows += $this->doUpdate($con); } $this->resetModified(); } if ($this->filesScheduledForDeletion !== null) { if (!$this->filesScheduledForDeletion->isEmpty()) { \App\Propel\FileQuery::create()->filterByPrimaryKeys($this->filesScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->filesScheduledForDeletion = null; } } if ($this->collFiles !== null) { foreach ($this->collFiles as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->fileTypeI18nsScheduledForDeletion !== null) { if (!$this->fileTypeI18nsScheduledForDeletion->isEmpty()) { \App\Propel\FileTypeI18nQuery::create()->filterByPrimaryKeys($this->fileTypeI18nsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->fileTypeI18nsScheduledForDeletion = null; } } if ($this->collFileTypeI18ns !== null) { foreach ($this->collFileTypeI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }