Esempio 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->auserSysRef !== null) {
             if ($this->auserSysRef->isModified() || $this->auserSysRef->isNew()) {
                 $affectedRows += $this->auserSysRef->save($con);
             }
             $this->setuserSysRef($this->auserSysRef);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->batchesScheduledForDeletion !== null) {
             if (!$this->batchesScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->batchesScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[1] = $this->getId();
                     $entryPk[0] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \RBatchForbookQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->batchesScheduledForDeletion = null;
             }
         }
         if ($this->collBatches) {
             foreach ($this->collBatches as $batch) {
                 if (!$batch->isDeleted() && ($batch->isNew() || $batch->isModified())) {
                     $batch->save($con);
                 }
             }
         }
         if ($this->rightssScheduledForDeletion !== null) {
             if (!$this->rightssScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->rightssScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[1] = $this->getId();
                     $entryPk[0] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \RRightsForbookQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->rightssScheduledForDeletion = null;
             }
         }
         if ($this->collRightss) {
             foreach ($this->collRightss as $rights) {
                 if (!$rights->isDeleted() && ($rights->isNew() || $rights->isModified())) {
                     $rights->save($con);
                 }
             }
         }
         if ($this->templatenamessScheduledForDeletion !== null) {
             if (!$this->templatenamessScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->templatenamessScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[1] = $this->getId();
                     $entryPk[0] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \RTemplatenamesForbookQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->templatenamessScheduledForDeletion = null;
             }
         }
         if ($this->collTemplatenamess) {
             foreach ($this->collTemplatenamess as $templatenames) {
                 if (!$templatenames->isDeleted() && ($templatenames->isNew() || $templatenames->isModified())) {
                     $templatenames->save($con);
                 }
             }
         }
         if ($this->rBatchForbooksScheduledForDeletion !== null) {
             if (!$this->rBatchForbooksScheduledForDeletion->isEmpty()) {
                 \RBatchForbookQuery::create()->filterByPrimaryKeys($this->rBatchForbooksScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->rBatchForbooksScheduledForDeletion = null;
             }
         }
         if ($this->collRBatchForbooks !== null) {
             foreach ($this->collRBatchForbooks as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->rRightsForbooksScheduledForDeletion !== null) {
             if (!$this->rRightsForbooksScheduledForDeletion->isEmpty()) {
                 \RRightsForbookQuery::create()->filterByPrimaryKeys($this->rRightsForbooksScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->rRightsForbooksScheduledForDeletion = null;
             }
         }
         if ($this->collRRightsForbooks !== null) {
             foreach ($this->collRRightsForbooks as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->rTemplatenamesForbooksScheduledForDeletion !== null) {
             if (!$this->rTemplatenamesForbooksScheduledForDeletion->isEmpty()) {
                 \RTemplatenamesForbookQuery::create()->filterByPrimaryKeys($this->rTemplatenamesForbooksScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->rTemplatenamesForbooksScheduledForDeletion = null;
             }
         }
         if ($this->collRTemplatenamesForbooks !== null) {
             foreach ($this->collRTemplatenamesForbooks as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->formatssScheduledForDeletion !== null) {
             if (!$this->formatssScheduledForDeletion->isEmpty()) {
                 \FormatsQuery::create()->filterByPrimaryKeys($this->formatssScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->formatssScheduledForDeletion = null;
             }
         }
         if ($this->collFormatss !== null) {
             foreach ($this->collFormatss as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->issuessScheduledForDeletion !== null) {
             if (!$this->issuessScheduledForDeletion->isEmpty()) {
                 \IssuesQuery::create()->filterByPrimaryKeys($this->issuessScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->issuessScheduledForDeletion = null;
             }
         }
         if ($this->collIssuess !== null) {
             foreach ($this->collIssuess as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }