Ejemplo n.º 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;
         // 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->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->subNotesScheduledForDeletion !== null) {
             if (!$this->subNotesScheduledForDeletion->isEmpty()) {
                 \Models\SubNoteQuery::create()->filterByPrimaryKeys($this->subNotesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->subNotesScheduledForDeletion = null;
             }
         }
         if ($this->collSubNotes !== null) {
             foreach ($this->collSubNotes as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->filesScheduledForDeletion !== null) {
             if (!$this->filesScheduledForDeletion->isEmpty()) {
                 \Models\FileQuery::create()->filterByPrimaryKeys($this->filesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->filesScheduledForDeletion = null;
             }
         }
         if ($this->collFiles !== null) {
             foreach ($this->collFiles as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->notificationsScheduledForDeletion !== null) {
             if (!$this->notificationsScheduledForDeletion->isEmpty()) {
                 foreach ($this->notificationsScheduledForDeletion as $notification) {
                     // need to save related object because we set the relation to null
                     $notification->save($con);
                 }
                 $this->notificationsScheduledForDeletion = null;
             }
         }
         if ($this->collNotifications !== null) {
             foreach ($this->collNotifications 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->sharedsScheduledForDeletion !== null) {
             if (!$this->sharedsScheduledForDeletion->isEmpty()) {
                 foreach ($this->sharedsScheduledForDeletion as $shared) {
                     // need to save related object because we set the relation to null
                     $shared->save($con);
                 }
                 $this->sharedsScheduledForDeletion = null;
             }
         }
         if ($this->collShareds !== null) {
             foreach ($this->collShareds as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Ejemplo n.º 2
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;
         // 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;
 }
Ejemplo n.º 3
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->groupsScheduledForDeletion !== null) {
             if (!$this->groupsScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->groupsScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[0] = $this->getId();
                     $entryPk[1] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \Models\UserGroupQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->groupsScheduledForDeletion = null;
             }
         }
         if ($this->collGroups) {
             foreach ($this->collGroups as $group) {
                 if (!$group->isDeleted() && ($group->isNew() || $group->isModified())) {
                     $group->save($con);
                 }
             }
         }
         if ($this->identitiesScheduledForDeletion !== null) {
             if (!$this->identitiesScheduledForDeletion->isEmpty()) {
                 \Models\IdentityQuery::create()->filterByPrimaryKeys($this->identitiesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->identitiesScheduledForDeletion = null;
             }
         }
         if ($this->collIdentities !== null) {
             foreach ($this->collIdentities as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->packPermissionsScheduledForDeletion !== null) {
             if (!$this->packPermissionsScheduledForDeletion->isEmpty()) {
                 \Models\PackPermissionQuery::create()->filterByPrimaryKeys($this->packPermissionsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->packPermissionsScheduledForDeletion = null;
             }
         }
         if ($this->collPackPermissions !== null) {
             foreach ($this->collPackPermissions as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->packsScheduledForDeletion !== null) {
             if (!$this->packsScheduledForDeletion->isEmpty()) {
                 \Models\PackQuery::create()->filterByPrimaryKeys($this->packsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->packsScheduledForDeletion = null;
             }
         }
         if ($this->collPacks !== null) {
             foreach ($this->collPacks as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->myGroupsScheduledForDeletion !== null) {
             if (!$this->myGroupsScheduledForDeletion->isEmpty()) {
                 \Models\GroupQuery::create()->filterByPrimaryKeys($this->myGroupsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->myGroupsScheduledForDeletion = null;
             }
         }
         if ($this->collMyGroups !== null) {
             foreach ($this->collMyGroups 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->userGroupsScheduledForDeletion !== null) {
             if (!$this->userGroupsScheduledForDeletion->isEmpty()) {
                 \Models\UserGroupQuery::create()->filterByPrimaryKeys($this->userGroupsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->userGroupsScheduledForDeletion = null;
             }
         }
         if ($this->collUserGroups !== null) {
             foreach ($this->collUserGroups as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Ejemplo n.º 4
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->commentsScheduledForDeletion !== null) {
             if (!$this->commentsScheduledForDeletion->isEmpty()) {
                 \propel2\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;
 }
 /**
  * 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->aCreator !== null) {
             if ($this->aCreator->isModified() || $this->aCreator->isNew()) {
                 $affectedRows += $this->aCreator->save($con);
             }
             $this->setCreator($this->aCreator);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->interestsScheduledForDeletion !== null) {
             if (!$this->interestsScheduledForDeletion->isEmpty()) {
                 \EventInterestQuery::create()->filterByPrimaryKeys($this->interestsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->interestsScheduledForDeletion = null;
             }
         }
         if ($this->collInterests !== null) {
             foreach ($this->collInterests as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->commentsScheduledForDeletion !== null) {
             if (!$this->commentsScheduledForDeletion->isEmpty()) {
                 \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;
 }
Ejemplo n.º 6
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->groupsScheduledForDeletion !== null) {
             if (!$this->groupsScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->groupsScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[0] = $this->getId();
                     $entryPk[1] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \Models\UserGroupQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->groupsScheduledForDeletion = null;
             }
         }
         if ($this->collGroups) {
             foreach ($this->collGroups as $group) {
                 if (!$group->isDeleted() && ($group->isNew() || $group->isModified())) {
                     $group->save($con);
                 }
             }
         }
         if ($this->notesScheduledForDeletion !== null) {
             if (!$this->notesScheduledForDeletion->isEmpty()) {
                 \Models\NoteQuery::create()->filterByPrimaryKeys($this->notesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->notesScheduledForDeletion = null;
             }
         }
         if ($this->collNotes !== null) {
             foreach ($this->collNotes as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->categoriesScheduledForDeletion !== null) {
             if (!$this->categoriesScheduledForDeletion->isEmpty()) {
                 \Models\CategoryQuery::create()->filterByPrimaryKeys($this->categoriesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->categoriesScheduledForDeletion = null;
             }
         }
         if ($this->collCategories !== null) {
             foreach ($this->collCategories as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->notificationsRelatedByUserIdScheduledForDeletion !== null) {
             if (!$this->notificationsRelatedByUserIdScheduledForDeletion->isEmpty()) {
                 \Models\NotificationQuery::create()->filterByPrimaryKeys($this->notificationsRelatedByUserIdScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->notificationsRelatedByUserIdScheduledForDeletion = null;
             }
         }
         if ($this->collNotificationsRelatedByUserId !== null) {
             foreach ($this->collNotificationsRelatedByUserId as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->notificationsRelatedByOriginTypeOriginIdScheduledForDeletion !== null) {
             if (!$this->notificationsRelatedByOriginTypeOriginIdScheduledForDeletion->isEmpty()) {
                 foreach ($this->notificationsRelatedByOriginTypeOriginIdScheduledForDeletion as $notificationRelatedByOriginTypeOriginId) {
                     // need to save related object because we set the relation to null
                     $notificationRelatedByOriginTypeOriginId->save($con);
                 }
                 $this->notificationsRelatedByOriginTypeOriginIdScheduledForDeletion = null;
             }
         }
         if ($this->collNotificationsRelatedByOriginTypeOriginId !== null) {
             foreach ($this->collNotificationsRelatedByOriginTypeOriginId 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->identitiesScheduledForDeletion !== null) {
             if (!$this->identitiesScheduledForDeletion->isEmpty()) {
                 \Models\IdentityQuery::create()->filterByPrimaryKeys($this->identitiesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->identitiesScheduledForDeletion = null;
             }
         }
         if ($this->collIdentities !== null) {
             foreach ($this->collIdentities as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->userGroupsScheduledForDeletion !== null) {
             if (!$this->userGroupsScheduledForDeletion->isEmpty()) {
                 \Models\UserGroupQuery::create()->filterByPrimaryKeys($this->userGroupsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->userGroupsScheduledForDeletion = null;
             }
         }
         if ($this->collUserGroups !== null) {
             foreach ($this->collUserGroups as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->sharedsScheduledForDeletion !== null) {
             if (!$this->sharedsScheduledForDeletion->isEmpty()) {
                 foreach ($this->sharedsScheduledForDeletion as $shared) {
                     // need to save related object because we set the relation to null
                     $shared->save($con);
                 }
                 $this->sharedsScheduledForDeletion = null;
             }
         }
         if ($this->collShareds !== null) {
             foreach ($this->collShareds as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }