Exemple #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->aOrder !== null) {
             if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
                 $affectedRows += $this->aOrder->save($con);
             }
             $this->setOrder($this->aOrder);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->countriesScheduledForDeletion !== null) {
             if (!$this->countriesScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 $pk = $this->getPrimaryKey();
                 foreach ($this->countriesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
                     $pks[] = array($remotePk, $pk);
                 }
                 OrderCouponCountryQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->countriesScheduledForDeletion = null;
             }
             foreach ($this->getCountries() as $country) {
                 if ($country->isModified()) {
                     $country->save($con);
                 }
             }
         } elseif ($this->collCountries) {
             foreach ($this->collCountries as $country) {
                 if ($country->isModified()) {
                     $country->save($con);
                 }
             }
         }
         if ($this->modulesScheduledForDeletion !== null) {
             if (!$this->modulesScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 $pk = $this->getPrimaryKey();
                 foreach ($this->modulesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
                     $pks[] = array($pk, $remotePk);
                 }
                 OrderCouponModuleQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->modulesScheduledForDeletion = null;
             }
             foreach ($this->getModules() as $module) {
                 if ($module->isModified()) {
                     $module->save($con);
                 }
             }
         } elseif ($this->collModules) {
             foreach ($this->collModules as $module) {
                 if ($module->isModified()) {
                     $module->save($con);
                 }
             }
         }
         if ($this->orderCouponCountriesScheduledForDeletion !== null) {
             if (!$this->orderCouponCountriesScheduledForDeletion->isEmpty()) {
                 \Thelia\Model\OrderCouponCountryQuery::create()->filterByPrimaryKeys($this->orderCouponCountriesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->orderCouponCountriesScheduledForDeletion = null;
             }
         }
         if ($this->collOrderCouponCountries !== null) {
             foreach ($this->collOrderCouponCountries as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->orderCouponModulesScheduledForDeletion !== null) {
             if (!$this->orderCouponModulesScheduledForDeletion->isEmpty()) {
                 \Thelia\Model\OrderCouponModuleQuery::create()->filterByPrimaryKeys($this->orderCouponModulesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->orderCouponModulesScheduledForDeletion = null;
             }
         }
         if ($this->collOrderCouponModules !== null) {
             foreach ($this->collOrderCouponModules as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Exemple #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->aOrder !== null) {
             if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
                 $affectedRows += $this->aOrder->save($con);
             }
             $this->setOrder($this->aOrder);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->orderProductAttributeCombinationsScheduledForDeletion !== null) {
             if (!$this->orderProductAttributeCombinationsScheduledForDeletion->isEmpty()) {
                 \Thelia\Model\OrderProductAttributeCombinationQuery::create()->filterByPrimaryKeys($this->orderProductAttributeCombinationsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->orderProductAttributeCombinationsScheduledForDeletion = null;
             }
         }
         if ($this->collOrderProductAttributeCombinations !== null) {
             foreach ($this->collOrderProductAttributeCombinations as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->orderProductTaxesScheduledForDeletion !== null) {
             if (!$this->orderProductTaxesScheduledForDeletion->isEmpty()) {
                 \Thelia\Model\OrderProductTaxQuery::create()->filterByPrimaryKeys($this->orderProductTaxesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->orderProductTaxesScheduledForDeletion = null;
             }
         }
         if ($this->collOrderProductTaxes !== null) {
             foreach ($this->collOrderProductTaxes as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Exemple #3
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->aOrder !== null) {
             if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
                 $affectedRows += $this->aOrder->save($con);
             }
             $this->setOrder($this->aOrder);
         }
         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;
 }