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->aSale !== null) {
             if ($this->aSale->isModified() || $this->aSale->isNew()) {
                 $affectedRows += $this->aSale->save($con);
             }
             $this->setSale($this->aSale);
         }
         if ($this->aProduct !== null) {
             if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
                 $affectedRows += $this->aProduct->save($con);
             }
             $this->setProduct($this->aProduct);
         }
         if ($this->aAttributeAv !== null) {
             if ($this->aAttributeAv->isModified() || $this->aAttributeAv->isNew()) {
                 $affectedRows += $this->aAttributeAv->save($con);
             }
             $this->setAttributeAv($this->aAttributeAv);
         }
         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;
 }
Esempio 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->aProduct !== null) {
             if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
                 $affectedRows += $this->aProduct->save($con);
             }
             $this->setProduct($this->aProduct);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->productSaleElementssScheduledForDeletion !== null) {
             if (!$this->productSaleElementssScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 $pk = $this->getPrimaryKey();
                 foreach ($this->productSaleElementssScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
                     $pks[] = array($remotePk, $pk);
                 }
                 ProductSaleElementsProductImageQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->productSaleElementssScheduledForDeletion = null;
             }
             foreach ($this->getProductSaleElementss() as $productSaleElements) {
                 if ($productSaleElements->isModified()) {
                     $productSaleElements->save($con);
                 }
             }
         } elseif ($this->collProductSaleElementss) {
             foreach ($this->collProductSaleElementss as $productSaleElements) {
                 if ($productSaleElements->isModified()) {
                     $productSaleElements->save($con);
                 }
             }
         }
         if ($this->productSaleElementsProductImagesScheduledForDeletion !== null) {
             if (!$this->productSaleElementsProductImagesScheduledForDeletion->isEmpty()) {
                 \Thelia\Model\ProductSaleElementsProductImageQuery::create()->filterByPrimaryKeys($this->productSaleElementsProductImagesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->productSaleElementsProductImagesScheduledForDeletion = null;
             }
         }
         if ($this->collProductSaleElementsProductImages !== null) {
             foreach ($this->collProductSaleElementsProductImages as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->productImageI18nsScheduledForDeletion !== null) {
             if (!$this->productImageI18nsScheduledForDeletion->isEmpty()) {
                 \Thelia\Model\ProductImageI18nQuery::create()->filterByPrimaryKeys($this->productImageI18nsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->productImageI18nsScheduledForDeletion = null;
             }
         }
         if ($this->collProductImageI18ns !== null) {
             foreach ($this->collProductImageI18ns as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }