/**
  * 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->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->aFittingRuleEntityRelatedByForkedid !== null) {
             if ($this->aFittingRuleEntityRelatedByForkedid->isModified() || $this->aFittingRuleEntityRelatedByForkedid->isNew()) {
                 $affectedRows += $this->aFittingRuleEntityRelatedByForkedid->save($con);
             }
             $this->setFittingRuleEntityRelatedByForkedid($this->aFittingRuleEntityRelatedByForkedid);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->fittingRuleEntitiesRelatedByIdScheduledForDeletion !== null) {
             if (!$this->fittingRuleEntitiesRelatedByIdScheduledForDeletion->isEmpty()) {
                 foreach ($this->fittingRuleEntitiesRelatedByIdScheduledForDeletion as $fittingRuleEntityRelatedById) {
                     // need to save related object because we set the relation to null
                     $fittingRuleEntityRelatedById->save($con);
                 }
                 $this->fittingRuleEntitiesRelatedByIdScheduledForDeletion = null;
             }
         }
         if ($this->collFittingRuleEntitiesRelatedById !== null) {
             foreach ($this->collFittingRuleEntitiesRelatedById as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->fittingRuleRowsScheduledForDeletion !== null) {
             if (!$this->fittingRuleRowsScheduledForDeletion->isEmpty()) {
                 \ECP\FittingRuleRowQuery::create()->filterByPrimaryKeys($this->fittingRuleRowsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->fittingRuleRowsScheduledForDeletion = null;
             }
         }
         if ($this->collFittingRuleRows !== null) {
             foreach ($this->collFittingRuleRows as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->rulesetFilterRulesScheduledForDeletion !== null) {
             if (!$this->rulesetFilterRulesScheduledForDeletion->isEmpty()) {
                 \ECP\RulesetFilterRuleQuery::create()->filterByPrimaryKeys($this->rulesetFilterRulesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->rulesetFilterRulesScheduledForDeletion = null;
             }
         }
         if ($this->collRulesetFilterRules !== null) {
             foreach ($this->collRulesetFilterRules 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->eveApisScheduledForDeletion !== null) {
             if (!$this->eveApisScheduledForDeletion->isEmpty()) {
                 \ECP\EveApiQuery::create()->filterByPrimaryKeys($this->eveApisScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->eveApisScheduledForDeletion = null;
             }
         }
         if ($this->collEveApis !== null) {
             foreach ($this->collEveApis as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->grouppeopleScheduledForDeletion !== null) {
             if (!$this->grouppeopleScheduledForDeletion->isEmpty()) {
                 \ECP\GroupPersonQuery::create()->filterByPrimaryKeys($this->grouppeopleScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->grouppeopleScheduledForDeletion = null;
             }
         }
         if ($this->collGrouppeople !== null) {
             foreach ($this->collGrouppeople as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->fittingRuleEntitiesScheduledForDeletion !== null) {
             if (!$this->fittingRuleEntitiesScheduledForDeletion->isEmpty()) {
                 \ECP\FittingRuleEntityQuery::create()->filterByPrimaryKeys($this->fittingRuleEntitiesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->fittingRuleEntitiesScheduledForDeletion = null;
             }
         }
         if ($this->collFittingRuleEntities !== null) {
             foreach ($this->collFittingRuleEntities as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->rulesetEntitiesScheduledForDeletion !== null) {
             if (!$this->rulesetEntitiesScheduledForDeletion->isEmpty()) {
                 \ECP\RulesetEntityQuery::create()->filterByPrimaryKeys($this->rulesetEntitiesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->rulesetEntitiesScheduledForDeletion = null;
             }
         }
         if ($this->collRulesetEntities !== null) {
             foreach ($this->collRulesetEntities as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->compositionEntitiesScheduledForDeletion !== null) {
             if (!$this->compositionEntitiesScheduledForDeletion->isEmpty()) {
                 \ECP\CompositionEntityQuery::create()->filterByPrimaryKeys($this->compositionEntitiesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->compositionEntitiesScheduledForDeletion = null;
             }
         }
         if ($this->collCompositionEntities !== null) {
             foreach ($this->collCompositionEntities as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }