示例#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->sessionsScheduledForDeletion !== null) {
             if (!$this->sessionsScheduledForDeletion->isEmpty()) {
                 \CyberdenBundle\Model\SessionQuery::create()->filterByPrimaryKeys($this->sessionsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->sessionsScheduledForDeletion = null;
             }
         }
         if ($this->collSessions !== null) {
             foreach ($this->collSessions as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
示例#2
0
文件: User.php 项目: keeko/core
 /**
  * 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;
                 }
                 \keeko\core\model\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->sessionsScheduledForDeletion !== null) {
             if (!$this->sessionsScheduledForDeletion->isEmpty()) {
                 \keeko\core\model\SessionQuery::create()->filterByPrimaryKeys($this->sessionsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->sessionsScheduledForDeletion = null;
             }
         }
         if ($this->collSessions !== null) {
             foreach ($this->collSessions as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->userGroupsScheduledForDeletion !== null) {
             if (!$this->userGroupsScheduledForDeletion->isEmpty()) {
                 \keeko\core\model\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->activitiesScheduledForDeletion !== null) {
             if (!$this->activitiesScheduledForDeletion->isEmpty()) {
                 \keeko\core\model\ActivityQuery::create()->filterByPrimaryKeys($this->activitiesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->activitiesScheduledForDeletion = null;
             }
         }
         if ($this->collActivities !== null) {
             foreach ($this->collActivities as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }