示例#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->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->aNotification !== null) {
             if ($this->aNotification->isModified() || $this->aNotification->isNew()) {
                 $affectedRows += $this->aNotification->save($con);
             }
             $this->setNotification($this->aNotification);
         }
         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;
 }
示例#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->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->creditPaymentsScheduledForDeletion !== null) {
             if (!$this->creditPaymentsScheduledForDeletion->isEmpty()) {
                 foreach ($this->creditPaymentsScheduledForDeletion as $creditPayment) {
                     // need to save related object because we set the relation to null
                     $creditPayment->save($con);
                 }
                 $this->creditPaymentsScheduledForDeletion = null;
             }
         }
         if ($this->collCreditPayments !== null) {
             foreach ($this->collCreditPayments as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->debitPaymentsScheduledForDeletion !== null) {
             if (!$this->debitPaymentsScheduledForDeletion->isEmpty()) {
                 foreach ($this->debitPaymentsScheduledForDeletion as $debitPayment) {
                     // need to save related object because we set the relation to null
                     $debitPayment->save($con);
                 }
                 $this->debitPaymentsScheduledForDeletion = null;
             }
         }
         if ($this->collDebitPayments !== null) {
             foreach ($this->collDebitPayments as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->purchaseHistoriesScheduledForDeletion !== null) {
             if (!$this->purchaseHistoriesScheduledForDeletion->isEmpty()) {
                 foreach ($this->purchaseHistoriesScheduledForDeletion as $purchaseHistory) {
                     // need to save related object because we set the relation to null
                     $purchaseHistory->save($con);
                 }
                 $this->purchaseHistoriesScheduledForDeletion = null;
             }
         }
         if ($this->collPurchaseHistories !== null) {
             foreach ($this->collPurchaseHistories as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->historiesScheduledForDeletion !== null) {
             if (!$this->historiesScheduledForDeletion->isEmpty()) {
                 foreach ($this->historiesScheduledForDeletion as $history) {
                     // need to save related object because we set the relation to null
                     $history->save($con);
                 }
                 $this->historiesScheduledForDeletion = null;
             }
         }
         if ($this->collHistories !== null) {
             foreach ($this->collHistories as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->salessScheduledForDeletion !== null) {
             if (!$this->salessScheduledForDeletion->isEmpty()) {
                 foreach ($this->salessScheduledForDeletion as $sales) {
                     // need to save related object because we set the relation to null
                     $sales->save($con);
                 }
                 $this->salessScheduledForDeletion = null;
             }
         }
         if ($this->collSaless !== null) {
             foreach ($this->collSaless as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->salesHistoriesScheduledForDeletion !== null) {
             if (!$this->salesHistoriesScheduledForDeletion->isEmpty()) {
                 foreach ($this->salesHistoriesScheduledForDeletion as $salesHistory) {
                     // need to save related object because we set the relation to null
                     $salesHistory->save($con);
                 }
                 $this->salesHistoriesScheduledForDeletion = null;
             }
         }
         if ($this->collSalesHistories !== null) {
             foreach ($this->collSalesHistories as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }