/** * 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->aImage !== null) { if ($this->aImage->isModified() || $this->aImage->isNew()) { $affectedRows += $this->aImage->save($con); } $this->setImage($this->aImage); } if ($this->aMember !== null) { if ($this->aMember->isModified() || $this->aMember->isNew()) { $affectedRows += $this->aMember->save($con); } $this->setMember($this->aMember); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); $affectedRows += 1; } else { $affectedRows += $this->doUpdate($con); } $this->resetModified(); } if ($this->articlesScheduledForDeletion !== null) { if (!$this->articlesScheduledForDeletion->isEmpty()) { \Models\ArticleQuery::create()->filterByPrimaryKeys($this->articlesScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->articlesScheduledForDeletion = null; } } if ($this->collArticles !== null) { foreach ($this->collArticles as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->commentsScheduledForDeletion !== null) { if (!$this->commentsScheduledForDeletion->isEmpty()) { \Models\CommentQuery::create()->filterByPrimaryKeys($this->commentsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->commentsScheduledForDeletion = null; } } if ($this->collComments !== null) { foreach ($this->collComments as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->ratingsScheduledForDeletion !== null) { if (!$this->ratingsScheduledForDeletion->isEmpty()) { \Models\RatingQuery::create()->filterByPrimaryKeys($this->ratingsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->ratingsScheduledForDeletion = null; } } if ($this->collRatings !== null) { foreach ($this->collRatings as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->userReportsRelatedByIdUserScheduledForDeletion !== null) { if (!$this->userReportsRelatedByIdUserScheduledForDeletion->isEmpty()) { \Models\UserReportQuery::create()->filterByPrimaryKeys($this->userReportsRelatedByIdUserScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->userReportsRelatedByIdUserScheduledForDeletion = null; } } if ($this->collUserReportsRelatedByIdUser !== null) { foreach ($this->collUserReportsRelatedByIdUser as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->userReportsRelatedByIdUserReportedScheduledForDeletion !== null) { if (!$this->userReportsRelatedByIdUserReportedScheduledForDeletion->isEmpty()) { \Models\UserReportQuery::create()->filterByPrimaryKeys($this->userReportsRelatedByIdUserReportedScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->userReportsRelatedByIdUserReportedScheduledForDeletion = null; } } if ($this->collUserReportsRelatedByIdUserReported !== null) { foreach ($this->collUserReportsRelatedByIdUserReported as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->bugReportsScheduledForDeletion !== null) { if (!$this->bugReportsScheduledForDeletion->isEmpty()) { \Models\BugReportQuery::create()->filterByPrimaryKeys($this->bugReportsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->bugReportsScheduledForDeletion = null; } } if ($this->collBugReports !== null) { foreach ($this->collBugReports as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->ideasRelatedByIdUserScheduledForDeletion !== null) { if (!$this->ideasRelatedByIdUserScheduledForDeletion->isEmpty()) { \Models\IdeaQuery::create()->filterByPrimaryKeys($this->ideasRelatedByIdUserScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->ideasRelatedByIdUserScheduledForDeletion = null; } } if ($this->collIdeasRelatedByIdUser !== null) { foreach ($this->collIdeasRelatedByIdUser as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->ideasRelatedByApprovedByScheduledForDeletion !== null) { if (!$this->ideasRelatedByApprovedByScheduledForDeletion->isEmpty()) { foreach ($this->ideasRelatedByApprovedByScheduledForDeletion as $ideaRelatedByApprovedBy) { // need to save related object because we set the relation to null $ideaRelatedByApprovedBy->save($con); } $this->ideasRelatedByApprovedByScheduledForDeletion = null; } } if ($this->collIdeasRelatedByApprovedBy !== null) { foreach ($this->collIdeasRelatedByApprovedBy as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->membershipApplicationsScheduledForDeletion !== null) { if (!$this->membershipApplicationsScheduledForDeletion->isEmpty()) { \Models\MembershipApplicationQuery::create()->filterByPrimaryKeys($this->membershipApplicationsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->membershipApplicationsScheduledForDeletion = null; } } if ($this->collMembershipApplications !== null) { foreach ($this->collMembershipApplications as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->galleriesScheduledForDeletion !== null) { if (!$this->galleriesScheduledForDeletion->isEmpty()) { foreach ($this->galleriesScheduledForDeletion as $gallery) { // need to save related object because we set the relation to null $gallery->save($con); } $this->galleriesScheduledForDeletion = null; } } if ($this->collGalleries !== null) { foreach ($this->collGalleries as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->bansRelatedByIdUserScheduledForDeletion !== null) { if (!$this->bansRelatedByIdUserScheduledForDeletion->isEmpty()) { \Models\BanQuery::create()->filterByPrimaryKeys($this->bansRelatedByIdUserScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->bansRelatedByIdUserScheduledForDeletion = null; } } if ($this->collBansRelatedByIdUser !== null) { foreach ($this->collBansRelatedByIdUser as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->bansRelatedByBannedByScheduledForDeletion !== null) { if (!$this->bansRelatedByBannedByScheduledForDeletion->isEmpty()) { \Models\BanQuery::create()->filterByPrimaryKeys($this->bansRelatedByBannedByScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->bansRelatedByBannedByScheduledForDeletion = null; } } if ($this->collBansRelatedByBannedBy !== null) { foreach ($this->collBansRelatedByBannedBy 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->aUser !== null) { if ($this->aUser->isModified() || $this->aUser->isNew()) { $affectedRows += $this->aUser->save($con); } $this->setUser($this->aUser); } if ($this->aImage !== null) { if ($this->aImage->isModified() || $this->aImage->isNew()) { $affectedRows += $this->aImage->save($con); } $this->setImage($this->aImage); } if ($this->aCategory !== null) { if ($this->aCategory->isModified() || $this->aCategory->isNew()) { $affectedRows += $this->aCategory->save($con); } $this->setCategory($this->aCategory); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); $affectedRows += 1; } else { $affectedRows += $this->doUpdate($con); } $this->resetModified(); } if ($this->commentsScheduledForDeletion !== null) { if (!$this->commentsScheduledForDeletion->isEmpty()) { \Models\CommentQuery::create()->filterByPrimaryKeys($this->commentsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->commentsScheduledForDeletion = null; } } if ($this->collComments !== null) { foreach ($this->collComments as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }