示例#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->rightssScheduledForDeletion !== null) {
             if (!$this->rightssScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->rightssScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[1] = $this->getId();
                     $entryPk[0] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \RRightsFortemplateQuery::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->bookssScheduledForDeletion !== null) {
             if (!$this->bookssScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->bookssScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[0] = $this->getId();
                     $entryPk[1] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \RTemplatenamesForbookQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->bookssScheduledForDeletion = null;
             }
         }
         if ($this->collBookss) {
             foreach ($this->collBookss as $books) {
                 if (!$books->isDeleted() && ($books->isNew() || $books->isModified())) {
                     $books->save($con);
                 }
             }
         }
         if ($this->formatssScheduledForDeletion !== null) {
             if (!$this->formatssScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->formatssScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[0] = $this->getId();
                     $entryPk[1] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \RTemplatenamesInchapterQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->formatssScheduledForDeletion = null;
             }
         }
         if ($this->collFormatss) {
             foreach ($this->collFormatss as $formats) {
                 if (!$formats->isDeleted() && ($formats->isNew() || $formats->isModified())) {
                     $formats->save($con);
                 }
             }
         }
         if ($this->rRightsFortemplatesScheduledForDeletion !== null) {
             if (!$this->rRightsFortemplatesScheduledForDeletion->isEmpty()) {
                 \RRightsFortemplateQuery::create()->filterByPrimaryKeys($this->rRightsFortemplatesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->rRightsFortemplatesScheduledForDeletion = null;
             }
         }
         if ($this->collRRightsFortemplates !== null) {
             foreach ($this->collRRightsFortemplates 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->rTemplatenamesInchaptersScheduledForDeletion !== null) {
             if (!$this->rTemplatenamesInchaptersScheduledForDeletion->isEmpty()) {
                 \RTemplatenamesInchapterQuery::create()->filterByPrimaryKeys($this->rTemplatenamesInchaptersScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->rTemplatenamesInchaptersScheduledForDeletion = null;
             }
         }
         if ($this->collRTemplatenamesInchapters !== null) {
             foreach ($this->collRTemplatenamesInchapters as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->contributionssScheduledForDeletion !== null) {
             if (!$this->contributionssScheduledForDeletion->isEmpty()) {
                 \ContributionsQuery::create()->filterByPrimaryKeys($this->contributionssScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->contributionssScheduledForDeletion = null;
             }
         }
         if ($this->collContributionss !== null) {
             foreach ($this->collContributionss as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->templatessScheduledForDeletion !== null) {
             if (!$this->templatessScheduledForDeletion->isEmpty()) {
                 \TemplatesQuery::create()->filterByPrimaryKeys($this->templatessScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->templatessScheduledForDeletion = null;
             }
         }
         if ($this->collTemplatess !== null) {
             foreach ($this->collTemplatess 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;
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->templatessScheduledForDeletion !== null) {
             if (!$this->templatessScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->templatessScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[0] = $this->getId();
                     $entryPk[1] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \RFieldpostprocessorForfieldQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->templatessScheduledForDeletion = null;
             }
         }
         if ($this->collTemplatess) {
             foreach ($this->collTemplatess as $templates) {
                 if (!$templates->isDeleted() && ($templates->isNew() || $templates->isModified())) {
                     $templates->save($con);
                 }
             }
         }
         if ($this->rFieldpostprocessorForfieldsScheduledForDeletion !== null) {
             if (!$this->rFieldpostprocessorForfieldsScheduledForDeletion->isEmpty()) {
                 \RFieldpostprocessorForfieldQuery::create()->filterByPrimaryKeys($this->rFieldpostprocessorForfieldsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->rFieldpostprocessorForfieldsScheduledForDeletion = null;
             }
         }
         if ($this->collRFieldpostprocessorForfields !== null) {
             foreach ($this->collRFieldpostprocessorForfields as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }