/** * 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->aPackage !== null) { if ($this->aPackage->isModified() || $this->aPackage->isNew()) { $affectedRows += $this->aPackage->save($con); } $this->setPackage($this->aPackage); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); $affectedRows += 1; } else { $affectedRows += $this->doUpdate($con); } $this->resetModified(); } if ($this->actionsScheduledForDeletion !== null) { if (!$this->actionsScheduledForDeletion->isEmpty()) { \keeko\core\model\ActionQuery::create()->filterByPrimaryKeys($this->actionsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->actionsScheduledForDeletion = null; } } if ($this->collActions !== null) { foreach ($this->collActions 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()) { $pks = array(); foreach ($this->usersScheduledForDeletion as $entry) { $entryPk = []; $entryPk[1] = $this->getId(); $entryPk[0] = $entry->getId(); $pks[] = $entryPk; } \keeko\core\model\UserGroupQuery::create()->filterByPrimaryKeys($pks)->delete($con); $this->usersScheduledForDeletion = null; } } if ($this->collUsers) { foreach ($this->collUsers as $user) { if (!$user->isDeleted() && ($user->isNew() || $user->isModified())) { $user->save($con); } } } if ($this->actionsScheduledForDeletion !== null) { if (!$this->actionsScheduledForDeletion->isEmpty()) { $pks = array(); foreach ($this->actionsScheduledForDeletion as $entry) { $entryPk = []; $entryPk[0] = $this->getId(); $entryPk[1] = $entry->getId(); $pks[] = $entryPk; } \keeko\core\model\GroupActionQuery::create()->filterByPrimaryKeys($pks)->delete($con); $this->actionsScheduledForDeletion = null; } } if ($this->collActions) { foreach ($this->collActions as $action) { if (!$action->isDeleted() && ($action->isNew() || $action->isModified())) { $action->save($con); } } } if ($this->userGroupsScheduledForDeletion !== null) { if (!$this->userGroupsScheduledForDeletion->isEmpty()) { \keeko\core\model\UserGroupQuery::create()->filterByPrimaryKeys($this->userGroupsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->userGroupsScheduledForDeletion = null; } } if ($this->collUserGroups !== null) { foreach ($this->collUserGroups as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->groupActionsScheduledForDeletion !== null) { if (!$this->groupActionsScheduledForDeletion->isEmpty()) { \keeko\core\model\GroupActionQuery::create()->filterByPrimaryKeys($this->groupActionsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->groupActionsScheduledForDeletion = null; } } if ($this->collGroupActions !== null) { foreach ($this->collGroupActions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }