Example #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->newsScheduledForDeletion !== null) {
             if (!$this->newsScheduledForDeletion->isEmpty()) {
                 \NewsQuery::create()->filterByPrimaryKeys($this->newsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->newsScheduledForDeletion = null;
             }
         }
         if ($this->collNews !== null) {
             foreach ($this->collNews as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->ratingHeaderssScheduledForDeletion !== null) {
             if (!$this->ratingHeaderssScheduledForDeletion->isEmpty()) {
                 \RatingHeadersQuery::create()->filterByPrimaryKeys($this->ratingHeaderssScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->ratingHeaderssScheduledForDeletion = null;
             }
         }
         if ($this->collRatingHeaderss !== null) {
             foreach ($this->collRatingHeaderss as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->rigssScheduledForDeletion !== null) {
             if (!$this->rigssScheduledForDeletion->isEmpty()) {
                 \RigsQuery::create()->filterByPrimaryKeys($this->rigssScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->rigssScheduledForDeletion = null;
             }
         }
         if ($this->collRigss !== null) {
             foreach ($this->collRigss as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->userAttributeValuessScheduledForDeletion !== null) {
             if (!$this->userAttributeValuessScheduledForDeletion->isEmpty()) {
                 \UserAttributeValuesQuery::create()->filterByPrimaryKeys($this->userAttributeValuessScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->userAttributeValuessScheduledForDeletion = null;
             }
         }
         if ($this->collUserAttributeValuess !== null) {
             foreach ($this->collUserAttributeValuess as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->userReviewssScheduledForDeletion !== null) {
             if (!$this->userReviewssScheduledForDeletion->isEmpty()) {
                 \UserReviewsQuery::create()->filterByPrimaryKeys($this->userReviewssScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->userReviewssScheduledForDeletion = null;
             }
         }
         if ($this->collUserReviewss !== null) {
             foreach ($this->collUserReviewss as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->userWeightssScheduledForDeletion !== null) {
             if (!$this->userWeightssScheduledForDeletion->isEmpty()) {
                 \UserWeightsQuery::create()->filterByPrimaryKeys($this->userWeightssScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->userWeightssScheduledForDeletion = null;
             }
         }
         if ($this->collUserWeightss !== null) {
             foreach ($this->collUserWeightss as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }