/**
  * 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;
         // 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->aRulesetRuleRow !== null) {
             if ($this->aRulesetRuleRow->isModified() || $this->aRulesetRuleRow->isNew()) {
                 $affectedRows += $this->aRulesetRuleRow->save($con);
             }
             $this->setRulesetRuleRow($this->aRulesetRuleRow);
         }
         if ($this->aconcatenationObj !== null) {
             if ($this->aconcatenationObj->isModified() || $this->aconcatenationObj->isNew()) {
                 $affectedRows += $this->aconcatenationObj->save($con);
             }
             $this->setconcatenationObj($this->aconcatenationObj);
         }
         if ($this->aFittingRuleEntity !== null) {
             if ($this->aFittingRuleEntity->isModified() || $this->aFittingRuleEntity->isNew()) {
                 $affectedRows += $this->aFittingRuleEntity->save($con);
             }
             $this->setFittingRuleEntity($this->aFittingRuleEntity);
         }
         if ($this->acomparisonObj !== null) {
             if ($this->acomparisonObj->isModified() || $this->acomparisonObj->isNew()) {
                 $affectedRows += $this->acomparisonObj->save($con);
             }
             $this->setcomparisonObj($this->acomparisonObj);
         }
         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;
 }
 /**
  * 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->aFittingRuleEntity !== null) {
             if ($this->aFittingRuleEntity->isModified() || $this->aFittingRuleEntity->isNew()) {
                 $affectedRows += $this->aFittingRuleEntity->save($con);
             }
             $this->setFittingRuleEntity($this->aFittingRuleEntity);
         }
         if ($this->aconcatenationObj !== null) {
             if ($this->aconcatenationObj->isModified() || $this->aconcatenationObj->isNew()) {
                 $affectedRows += $this->aconcatenationObj->save($con);
             }
             $this->setconcatenationObj($this->aconcatenationObj);
         }
         if ($this->acomparisonObj !== null) {
             if ($this->acomparisonObj->isModified() || $this->acomparisonObj->isNew()) {
                 $affectedRows += $this->acomparisonObj->save($con);
             }
             $this->setcomparisonObj($this->acomparisonObj);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->itemFilterRulesScheduledForDeletion !== null) {
             if (!$this->itemFilterRulesScheduledForDeletion->isEmpty()) {
                 \ECP\ItemFilterRuleQuery::create()->filterByPrimaryKeys($this->itemFilterRulesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->itemFilterRulesScheduledForDeletion = null;
             }
         }
         if ($this->collItemFilterRules !== null) {
             foreach ($this->collItemFilterRules as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->itemFilterTypesScheduledForDeletion !== null) {
             if (!$this->itemFilterTypesScheduledForDeletion->isEmpty()) {
                 \ECP\ItemFilterTypeQuery::create()->filterByPrimaryKeys($this->itemFilterTypesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->itemFilterTypesScheduledForDeletion = null;
             }
         }
         if ($this->collItemFilterTypes !== null) {
             foreach ($this->collItemFilterTypes as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }