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 PropelPDO $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(PropelPDO $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->aGroup !== null) {
             if ($this->aGroup->isModified() || $this->aGroup->isNew()) {
                 $affectedRows += $this->aGroup->save($con);
             }
             $this->setGroup($this->aGroup);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $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 PropelPDO $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(PropelPDO $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->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->cyclicalEventssScheduledForDeletion !== null) {
             if (!$this->cyclicalEventssScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 $pk = $this->getPrimaryKey();
                 foreach ($this->cyclicalEventssScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
                     $pks[] = array($remotePk, $pk);
                 }
                 CyclicalEventHasListQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->cyclicalEventssScheduledForDeletion = null;
             }
             foreach ($this->getCyclicalEventss() as $cyclicalEvents) {
                 if ($cyclicalEvents->isModified()) {
                     $cyclicalEvents->save($con);
                 }
             }
         } elseif ($this->collCyclicalEventss) {
             foreach ($this->collCyclicalEventss as $cyclicalEvents) {
                 if ($cyclicalEvents->isModified()) {
                     $cyclicalEvents->save($con);
                 }
             }
         }
         if ($this->eventssScheduledForDeletion !== null) {
             if (!$this->eventssScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 $pk = $this->getPrimaryKey();
                 foreach ($this->eventssScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
                     $pks[] = array($remotePk, $pk);
                 }
                 EventHasListQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->eventssScheduledForDeletion = null;
             }
             foreach ($this->getEventss() as $events) {
                 if ($events->isModified()) {
                     $events->save($con);
                 }
             }
         } elseif ($this->collEventss) {
             foreach ($this->collEventss as $events) {
                 if ($events->isModified()) {
                     $events->save($con);
                 }
             }
         }
         if ($this->customListElementsScheduledForDeletion !== null) {
             if (!$this->customListElementsScheduledForDeletion->isEmpty()) {
                 CustomListElementQuery::create()->filterByPrimaryKeys($this->customListElementsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->customListElementsScheduledForDeletion = null;
             }
         }
         if ($this->collCustomListElements !== null) {
             foreach ($this->collCustomListElements as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->cyclicalEventHasListsScheduledForDeletion !== null) {
             if (!$this->cyclicalEventHasListsScheduledForDeletion->isEmpty()) {
                 CyclicalEventHasListQuery::create()->filterByPrimaryKeys($this->cyclicalEventHasListsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->cyclicalEventHasListsScheduledForDeletion = null;
             }
         }
         if ($this->collCyclicalEventHasLists !== null) {
             foreach ($this->collCyclicalEventHasLists as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->eventHasListsScheduledForDeletion !== null) {
             if (!$this->eventHasListsScheduledForDeletion->isEmpty()) {
                 EventHasListQuery::create()->filterByPrimaryKeys($this->eventHasListsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->eventHasListsScheduledForDeletion = null;
             }
         }
         if ($this->collEventHasLists !== null) {
             foreach ($this->collEventHasLists as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }