/** * 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->activitiesRelatedByObjectIdScheduledForDeletion !== null) { if (!$this->activitiesRelatedByObjectIdScheduledForDeletion->isEmpty()) { \keeko\core\model\ActivityQuery::create()->filterByPrimaryKeys($this->activitiesRelatedByObjectIdScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->activitiesRelatedByObjectIdScheduledForDeletion = null; } } if ($this->collActivitiesRelatedByObjectId !== null) { foreach ($this->collActivitiesRelatedByObjectId as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->activitiesRelatedByTargetIdScheduledForDeletion !== null) { if (!$this->activitiesRelatedByTargetIdScheduledForDeletion->isEmpty()) { foreach ($this->activitiesRelatedByTargetIdScheduledForDeletion as $activityRelatedByTargetId) { // need to save related object because we set the relation to null $activityRelatedByTargetId->save($con); } $this->activitiesRelatedByTargetIdScheduledForDeletion = null; } } if ($this->collActivitiesRelatedByTargetId !== null) { foreach ($this->collActivitiesRelatedByTargetId 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->groupsScheduledForDeletion !== null) { if (!$this->groupsScheduledForDeletion->isEmpty()) { $pks = array(); foreach ($this->groupsScheduledForDeletion as $entry) { $entryPk = []; $entryPk[0] = $this->getId(); $entryPk[1] = $entry->getId(); $pks[] = $entryPk; } \keeko\core\model\UserGroupQuery::create()->filterByPrimaryKeys($pks)->delete($con); $this->groupsScheduledForDeletion = null; } } if ($this->collGroups) { foreach ($this->collGroups as $group) { if (!$group->isDeleted() && ($group->isNew() || $group->isModified())) { $group->save($con); } } } if ($this->sessionsScheduledForDeletion !== null) { if (!$this->sessionsScheduledForDeletion->isEmpty()) { \keeko\core\model\SessionQuery::create()->filterByPrimaryKeys($this->sessionsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->sessionsScheduledForDeletion = null; } } if ($this->collSessions !== null) { foreach ($this->collSessions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->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->activitiesScheduledForDeletion !== null) { if (!$this->activitiesScheduledForDeletion->isEmpty()) { \keeko\core\model\ActivityQuery::create()->filterByPrimaryKeys($this->activitiesScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->activitiesScheduledForDeletion = null; } } if ($this->collActivities !== null) { foreach ($this->collActivities as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }