Exemplo 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->aLocalization !== null) {
             if ($this->aLocalization->isModified() || $this->aLocalization->isNew()) {
                 $affectedRows += $this->aLocalization->save($con);
             }
             $this->setLocalization($this->aLocalization);
         }
         if ($this->aLanguageVariant !== null) {
             if ($this->aLanguageVariant->isModified() || $this->aLanguageVariant->isNew()) {
                 $affectedRows += $this->aLanguageVariant->save($con);
             }
             $this->setLanguageVariant($this->aLanguageVariant);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Exemplo 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->aParent !== null) {
             if ($this->aParent->isModified() || $this->aParent->isNew()) {
                 $affectedRows += $this->aParent->save($con);
             }
             $this->setParent($this->aParent);
         }
         if ($this->aLanguage !== null) {
             if ($this->aLanguage->isModified() || $this->aLanguage->isNew()) {
                 $affectedRows += $this->aLanguage->save($con);
             }
             $this->setLanguage($this->aLanguage);
         }
         if ($this->aExtLang !== null) {
             if ($this->aExtLang->isModified() || $this->aExtLang->isNew()) {
                 $affectedRows += $this->aExtLang->save($con);
             }
             $this->setExtLang($this->aExtLang);
         }
         if ($this->aScript !== null) {
             if ($this->aScript->isModified() || $this->aScript->isNew()) {
                 $affectedRows += $this->aScript->save($con);
             }
             $this->setScript($this->aScript);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->languageVariantsScheduledForDeletion !== null) {
             if (!$this->languageVariantsScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 foreach ($this->languageVariantsScheduledForDeletion as $entry) {
                     $entryPk = [];
                     $entryPk[0] = $this->getId();
                     $entryPk[1] = $entry->getId();
                     $pks[] = $entryPk;
                 }
                 \keeko\core\model\LocalizationVariantQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->languageVariantsScheduledForDeletion = null;
             }
         }
         if ($this->collLanguageVariants) {
             foreach ($this->collLanguageVariants as $languageVariant) {
                 if (!$languageVariant->isDeleted() && ($languageVariant->isNew() || $languageVariant->isModified())) {
                     $languageVariant->save($con);
                 }
             }
         }
         if ($this->localizationsRelatedByIdScheduledForDeletion !== null) {
             if (!$this->localizationsRelatedByIdScheduledForDeletion->isEmpty()) {
                 foreach ($this->localizationsRelatedByIdScheduledForDeletion as $localizationRelatedById) {
                     // need to save related object because we set the relation to null
                     $localizationRelatedById->save($con);
                 }
                 $this->localizationsRelatedByIdScheduledForDeletion = null;
             }
         }
         if ($this->collLocalizationsRelatedById !== null) {
             foreach ($this->collLocalizationsRelatedById as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->localizationVariantsScheduledForDeletion !== null) {
             if (!$this->localizationVariantsScheduledForDeletion->isEmpty()) {
                 \keeko\core\model\LocalizationVariantQuery::create()->filterByPrimaryKeys($this->localizationVariantsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->localizationVariantsScheduledForDeletion = null;
             }
         }
         if ($this->collLocalizationVariants !== null) {
             foreach ($this->collLocalizationVariants as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->applicationUrisScheduledForDeletion !== null) {
             if (!$this->applicationUrisScheduledForDeletion->isEmpty()) {
                 \keeko\core\model\ApplicationUriQuery::create()->filterByPrimaryKeys($this->applicationUrisScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->applicationUrisScheduledForDeletion = null;
             }
         }
         if ($this->collApplicationUris !== null) {
             foreach ($this->collApplicationUris as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }