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      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->aFileType !== null) {
             if ($this->aFileType->isModified() || $this->aFileType->isNew()) {
                 $affectedRows += $this->aFileType->save($con);
             }
             $this->setFileType($this->aFileType);
         }
         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;
 }
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      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->aFileType !== null) {
             if ($this->aFileType->isModified() || $this->aFileType->isNew()) {
                 $affectedRows += $this->aFileType->save($con);
             }
             $this->setFileType($this->aFileType);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->categoriesScheduledForDeletion !== null) {
             if (!$this->categoriesScheduledForDeletion->isEmpty()) {
                 foreach ($this->categoriesScheduledForDeletion as $category) {
                     // need to save related object because we set the relation to null
                     $category->save($con);
                 }
                 $this->categoriesScheduledForDeletion = null;
             }
         }
         if ($this->collCategories !== null) {
             foreach ($this->collCategories as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->newsScheduledForDeletion !== null) {
             if (!$this->newsScheduledForDeletion->isEmpty()) {
                 foreach ($this->newsScheduledForDeletion as $news) {
                     // need to save related object because we set the relation to null
                     $news->save($con);
                 }
                 $this->newsScheduledForDeletion = null;
             }
         }
         if ($this->collNews !== null) {
             foreach ($this->collNews as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->periodicPlansScheduledForDeletion !== null) {
             if (!$this->periodicPlansScheduledForDeletion->isEmpty()) {
                 foreach ($this->periodicPlansScheduledForDeletion as $periodicPlan) {
                     // need to save related object because we set the relation to null
                     $periodicPlan->save($con);
                 }
                 $this->periodicPlansScheduledForDeletion = null;
             }
         }
         if ($this->collPeriodicPlans !== null) {
             foreach ($this->collPeriodicPlans as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->productsScheduledForDeletion !== null) {
             if (!$this->productsScheduledForDeletion->isEmpty()) {
                 foreach ($this->productsScheduledForDeletion as $product) {
                     // need to save related object because we set the relation to null
                     $product->save($con);
                 }
                 $this->productsScheduledForDeletion = null;
             }
         }
         if ($this->collProducts !== null) {
             foreach ($this->collProducts as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->providersScheduledForDeletion !== null) {
             if (!$this->providersScheduledForDeletion->isEmpty()) {
                 foreach ($this->providersScheduledForDeletion as $provider) {
                     // need to save related object because we set the relation to null
                     $provider->save($con);
                 }
                 $this->providersScheduledForDeletion = null;
             }
         }
         if ($this->collProviders !== null) {
             foreach ($this->collProviders as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->resourceFilesScheduledForDeletion !== null) {
             if (!$this->resourceFilesScheduledForDeletion->isEmpty()) {
                 \App\Propel\ResourceFileQuery::create()->filterByPrimaryKeys($this->resourceFilesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->resourceFilesScheduledForDeletion = null;
             }
         }
         if ($this->collResourceFiles !== null) {
             foreach ($this->collResourceFiles as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->usersScheduledForDeletion !== null) {
             if (!$this->usersScheduledForDeletion->isEmpty()) {
                 foreach ($this->usersScheduledForDeletion as $user) {
                     // need to save related object because we set the relation to null
                     $user->save($con);
                 }
                 $this->usersScheduledForDeletion = null;
             }
         }
         if ($this->collUsers !== null) {
             foreach ($this->collUsers as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }