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;
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->objectsScheduledForDeletion !== null) {
             if (!$this->objectsScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->objectsScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[1] = $this->getId();
                     $entryPk[0] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \ObjectCategoryQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->objectsScheduledForDeletion = null;
             }
         }
         if ($this->collObjects) {
             foreach ($this->collObjects as $object) {
                 if (!$object->isDeleted() && ($object->isNew() || $object->isModified())) {
                     $object->save($con);
                 }
             }
         }
         if ($this->objectCategoriesScheduledForDeletion !== null) {
             if (!$this->objectCategoriesScheduledForDeletion->isEmpty()) {
                 \ObjectCategoryQuery::create()->filterByPrimaryKeys($this->objectCategoriesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->objectCategoriesScheduledForDeletion = null;
             }
         }
         if ($this->collObjectCategories !== null) {
             foreach ($this->collObjectCategories as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $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;
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->objectsScheduledForDeletion !== null) {
             if (!$this->objectsScheduledForDeletion->isEmpty()) {
                 \gossi\trixionary\model\ObjectQuery::create()->filterByPrimaryKeys($this->objectsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->objectsScheduledForDeletion = null;
             }
         }
         if ($this->collObjects !== null) {
             foreach ($this->collObjects as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->positionsScheduledForDeletion !== null) {
             if (!$this->positionsScheduledForDeletion->isEmpty()) {
                 \gossi\trixionary\model\PositionQuery::create()->filterByPrimaryKeys($this->positionsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->positionsScheduledForDeletion = null;
             }
         }
         if ($this->collPositions !== null) {
             foreach ($this->collPositions as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->skillsScheduledForDeletion !== null) {
             if (!$this->skillsScheduledForDeletion->isEmpty()) {
                 \gossi\trixionary\model\SkillQuery::create()->filterByPrimaryKeys($this->skillsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->skillsScheduledForDeletion = null;
             }
         }
         if ($this->collSkills !== null) {
             foreach ($this->collSkills as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->groupsScheduledForDeletion !== null) {
             if (!$this->groupsScheduledForDeletion->isEmpty()) {
                 \gossi\trixionary\model\GroupQuery::create()->filterByPrimaryKeys($this->groupsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->groupsScheduledForDeletion = null;
             }
         }
         if ($this->collGroups !== null) {
             foreach ($this->collGroups as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }