示例#1
0
文件: Games.php 项目: nirkbirk/site
 /**
  * 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->aCompaniesRelatedByPublisherId !== null) {
             if ($this->aCompaniesRelatedByPublisherId->isModified() || $this->aCompaniesRelatedByPublisherId->isNew()) {
                 $affectedRows += $this->aCompaniesRelatedByPublisherId->save($con);
             }
             $this->setCompaniesRelatedByPublisherId($this->aCompaniesRelatedByPublisherId);
         }
         if ($this->aCompaniesRelatedByDeveloperId !== null) {
             if ($this->aCompaniesRelatedByDeveloperId->isModified() || $this->aCompaniesRelatedByDeveloperId->isNew()) {
                 $affectedRows += $this->aCompaniesRelatedByDeveloperId->save($con);
             }
             $this->setCompaniesRelatedByDeveloperId($this->aCompaniesRelatedByDeveloperId);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->gameLinkssScheduledForDeletion !== null) {
             if (!$this->gameLinkssScheduledForDeletion->isEmpty()) {
                 \GameLinksQuery::create()->filterByPrimaryKeys($this->gameLinkssScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->gameLinkssScheduledForDeletion = null;
             }
         }
         if ($this->collGameLinkss !== null) {
             foreach ($this->collGameLinkss as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->gamePlatformssScheduledForDeletion !== null) {
             if (!$this->gamePlatformssScheduledForDeletion->isEmpty()) {
                 \GamePlatformsQuery::create()->filterByPrimaryKeys($this->gamePlatformssScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->gamePlatformssScheduledForDeletion = null;
             }
         }
         if ($this->collGamePlatformss !== null) {
             foreach ($this->collGamePlatformss 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->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);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }