/** * 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); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } if ($this->notificationOptionsScheduledForDeletion !== null) { if (!$this->notificationOptionsScheduledForDeletion->isEmpty()) { \ORM\NotificationOptionQuery::create()->filterByPrimaryKeys($this->notificationOptionsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->notificationOptionsScheduledForDeletion = null; } } if ($this->collNotificationOptions !== null) { foreach ($this->collNotificationOptions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->singlePermission !== null) { if (!$this->singlePermission->isDeleted() && ($this->singlePermission->isNew() || $this->singlePermission->isModified())) { $affectedRows += $this->singlePermission->save($con); } } if ($this->usersScheduledForDeletion !== null) { if (!$this->usersScheduledForDeletion->isEmpty()) { \ORM\UserQuery::create()->filterByPrimaryKeys($this->usersScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->usersScheduledForDeletion = null; } } if ($this->collUsers !== null) { foreach ($this->collUsers 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->usersScheduledForDeletion !== null) { if (!$this->usersScheduledForDeletion->isEmpty()) { \Jalle19\StatusManager\Database\UserQuery::create()->filterByPrimaryKeys($this->usersScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->usersScheduledForDeletion = null; } } if ($this->collUsers !== null) { foreach ($this->collUsers as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->connectionsScheduledForDeletion !== null) { if (!$this->connectionsScheduledForDeletion->isEmpty()) { \Jalle19\StatusManager\Database\ConnectionQuery::create()->filterByPrimaryKeys($this->connectionsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->connectionsScheduledForDeletion = null; } } if ($this->collConnections !== null) { foreach ($this->collConnections as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->inputsScheduledForDeletion !== null) { if (!$this->inputsScheduledForDeletion->isEmpty()) { \Jalle19\StatusManager\Database\InputQuery::create()->filterByPrimaryKeys($this->inputsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->inputsScheduledForDeletion = null; } } if ($this->collInputs !== null) { foreach ($this->collInputs as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->channelsScheduledForDeletion !== null) { if (!$this->channelsScheduledForDeletion->isEmpty()) { \Jalle19\StatusManager\Database\ChannelQuery::create()->filterByPrimaryKeys($this->channelsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->channelsScheduledForDeletion = null; } } if ($this->collChannels !== null) { foreach ($this->collChannels as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->subscriptionsScheduledForDeletion !== null) { if (!$this->subscriptionsScheduledForDeletion->isEmpty()) { \Jalle19\StatusManager\Database\SubscriptionQuery::create()->filterByPrimaryKeys($this->subscriptionsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->subscriptionsScheduledForDeletion = null; } } if ($this->collSubscriptions !== null) { foreach ($this->collSubscriptions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }