Exemple #1
0
 /**
  * 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->aSkill !== null) {
             if ($this->aSkill->isModified() || $this->aSkill->isNew()) {
                 $affectedRows += $this->aSkill->save($con);
             }
             $this->setSkill($this->aSkill);
         }
         if ($this->aReference !== null) {
             if ($this->aReference->isModified() || $this->aReference->isNew()) {
                 $affectedRows += $this->aReference->save($con);
             }
             $this->setReference($this->aReference);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Exemple #2
0
 /**
  * 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->aStructureNode !== null) {
             if ($this->aStructureNode->isModified() || $this->aStructureNode->isNew()) {
                 $affectedRows += $this->aStructureNode->save($con);
             }
             $this->setStructureNode($this->aStructureNode);
         }
         if ($this->aSkillRelatedBySkillId !== null) {
             if ($this->aSkillRelatedBySkillId->isModified() || $this->aSkillRelatedBySkillId->isNew()) {
                 $affectedRows += $this->aSkillRelatedBySkillId->save($con);
             }
             $this->setSkillRelatedBySkillId($this->aSkillRelatedBySkillId);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->rootSkillsScheduledForDeletion !== null) {
             if (!$this->rootSkillsScheduledForDeletion->isEmpty()) {
                 foreach ($this->rootSkillsScheduledForDeletion as $rootSkill) {
                     // need to save related object because we set the relation to null
                     $rootSkill->save($con);
                 }
                 $this->rootSkillsScheduledForDeletion = null;
             }
         }
         if ($this->collRootSkills !== null) {
             foreach ($this->collRootSkills as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Exemple #3
0
 /**
  * @param Skill $skill
  * @param mixed $data
  */
 protected function preSave(Skill $skill)
 {
     // set slug
     if (Text::create($skill->getSlug())->isEmpty()) {
         $name = str_replace('°', '', $skill->getName());
         $slugifier = new Slugify();
         $skill->setSlug($slugifier->slugify($name));
     }
     $this->isNew = $skill->isNew();
 }
Exemple #4
0
 /**
  * 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->aSkill !== null) {
             if ($this->aSkill->isModified() || $this->aSkill->isNew()) {
                 $affectedRows += $this->aSkill->save($con);
             }
             $this->setSkill($this->aSkill);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->structureNodesRelatedByParentIdScheduledForDeletion !== null) {
             if (!$this->structureNodesRelatedByParentIdScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->structureNodesRelatedByParentIdScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[0] = $this->getId();
                     $entryPk[1] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \gossi\trixionary\model\StructureNodeParentQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->structureNodesRelatedByParentIdScheduledForDeletion = null;
             }
         }
         if ($this->collStructureNodesRelatedByParentId) {
             foreach ($this->collStructureNodesRelatedByParentId as $structureNodeRelatedByParentId) {
                 if (!$structureNodeRelatedByParentId->isDeleted() && ($structureNodeRelatedByParentId->isNew() || $structureNodeRelatedByParentId->isModified())) {
                     $structureNodeRelatedByParentId->save($con);
                 }
             }
         }
         if ($this->structureNodesRelatedByStructureNodeIdScheduledForDeletion !== null) {
             if (!$this->structureNodesRelatedByStructureNodeIdScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->structureNodesRelatedByStructureNodeIdScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[1] = $this->getId();
                     $entryPk[0] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \gossi\trixionary\model\StructureNodeParentQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->structureNodesRelatedByStructureNodeIdScheduledForDeletion = null;
             }
         }
         if ($this->collStructureNodesRelatedByStructureNodeId) {
             foreach ($this->collStructureNodesRelatedByStructureNodeId as $structureNodeRelatedByStructureNodeId) {
                 if (!$structureNodeRelatedByStructureNodeId->isDeleted() && ($structureNodeRelatedByStructureNodeId->isNew() || $structureNodeRelatedByStructureNodeId->isModified())) {
                     $structureNodeRelatedByStructureNodeId->save($con);
                 }
             }
         }
         if ($this->structureNodeParentsRelatedByStructureNodeIdScheduledForDeletion !== null) {
             if (!$this->structureNodeParentsRelatedByStructureNodeIdScheduledForDeletion->isEmpty()) {
                 \gossi\trixionary\model\StructureNodeParentQuery::create()->filterByPrimaryKeys($this->structureNodeParentsRelatedByStructureNodeIdScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->structureNodeParentsRelatedByStructureNodeIdScheduledForDeletion = null;
             }
         }
         if ($this->collStructureNodeParentsRelatedByStructureNodeId !== null) {
             foreach ($this->collStructureNodeParentsRelatedByStructureNodeId as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->structureNodeParentsRelatedByParentIdScheduledForDeletion !== null) {
             if (!$this->structureNodeParentsRelatedByParentIdScheduledForDeletion->isEmpty()) {
                 \gossi\trixionary\model\StructureNodeParentQuery::create()->filterByPrimaryKeys($this->structureNodeParentsRelatedByParentIdScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->structureNodeParentsRelatedByParentIdScheduledForDeletion = null;
             }
         }
         if ($this->collStructureNodeParentsRelatedByParentId !== null) {
             foreach ($this->collStructureNodeParentsRelatedByParentId as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->singleKstruktur !== null) {
             if (!$this->singleKstruktur->isDeleted() && ($this->singleKstruktur->isNew() || $this->singleKstruktur->isModified())) {
                 $affectedRows += $this->singleKstruktur->save($con);
             }
         }
         if ($this->singleFunctionPhase !== null) {
             if (!$this->singleFunctionPhase->isDeleted() && ($this->singleFunctionPhase->isNew() || $this->singleFunctionPhase->isModified())) {
                 $affectedRows += $this->singleFunctionPhase->save($con);
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }