/** * 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->aSport !== null) { if ($this->aSport->isModified() || $this->aSport->isNew()) { $affectedRows += $this->aSport->save($con); } $this->setSport($this->aSport); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); $affectedRows += 1; } else { $affectedRows += $this->doUpdate($con); } $this->resetModified(); } if ($this->skillsScheduledForDeletion !== null) { if (!$this->skillsScheduledForDeletion->isEmpty()) { $pks = array(); foreach ($this->skillsScheduledForDeletion as $entry) { $entryPk = []; $entryPk[1] = $this->getId(); $entryPk[0] = $entry->getId(); $pks[] = $entryPk; } \gossi\trixionary\model\SkillGroupQuery::create()->filterByPrimaryKeys($pks)->delete($con); $this->skillsScheduledForDeletion = null; } } if ($this->collSkills) { foreach ($this->collSkills as $skill) { if (!$skill->isDeleted() && ($skill->isNew() || $skill->isModified())) { $skill->save($con); } } } if ($this->skillGroupsScheduledForDeletion !== null) { if (!$this->skillGroupsScheduledForDeletion->isEmpty()) { \gossi\trixionary\model\SkillGroupQuery::create()->filterByPrimaryKeys($this->skillGroupsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->skillGroupsScheduledForDeletion = null; } } if ($this->collSkillGroups !== null) { foreach ($this->collSkillGroups 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; // 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->aSport !== null) { if ($this->aSport->isModified() || $this->aSport->isNew()) { $affectedRows += $this->aSport->save($con); } $this->setSport($this->aSport); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); $affectedRows += 1; } else { $affectedRows += $this->doUpdate($con); } $this->resetModified(); } if ($this->skillsRelatedByStartPositionIdScheduledForDeletion !== null) { if (!$this->skillsRelatedByStartPositionIdScheduledForDeletion->isEmpty()) { foreach ($this->skillsRelatedByStartPositionIdScheduledForDeletion as $skillRelatedByStartPositionId) { // need to save related object because we set the relation to null $skillRelatedByStartPositionId->save($con); } $this->skillsRelatedByStartPositionIdScheduledForDeletion = null; } } if ($this->collSkillsRelatedByStartPositionId !== null) { foreach ($this->collSkillsRelatedByStartPositionId as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->skillsRelatedByEndPositionIdScheduledForDeletion !== null) { if (!$this->skillsRelatedByEndPositionIdScheduledForDeletion->isEmpty()) { foreach ($this->skillsRelatedByEndPositionIdScheduledForDeletion as $skillRelatedByEndPositionId) { // need to save related object because we set the relation to null $skillRelatedByEndPositionId->save($con); } $this->skillsRelatedByEndPositionIdScheduledForDeletion = null; } } if ($this->collSkillsRelatedByEndPositionId !== null) { foreach ($this->collSkillsRelatedByEndPositionId as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }