示例#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 PropelPDO $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(PropelPDO $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->aMedico !== null) {
             if ($this->aMedico->isModified() || $this->aMedico->isNew()) {
                 $affectedRows += $this->aMedico->save($con);
             }
             $this->setMedico($this->aMedico);
         }
         if ($this->aPaciente !== null) {
             if ($this->aPaciente->isModified() || $this->aPaciente->isNew()) {
                 $affectedRows += $this->aPaciente->save($con);
             }
             $this->setPaciente($this->aPaciente);
         }
         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 PropelPDO $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(PropelPDO $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->aConsultorio !== null) {
             if ($this->aConsultorio->isModified() || $this->aConsultorio->isNew()) {
                 $affectedRows += $this->aConsultorio->save($con);
             }
             $this->setConsultorio($this->aConsultorio);
         }
         if ($this->aMedico !== null) {
             if ($this->aMedico->isModified() || $this->aMedico->isNew()) {
                 $affectedRows += $this->aMedico->save($con);
             }
             $this->setMedico($this->aMedico);
         }
         if ($this->aPaciente !== null) {
             if ($this->aPaciente->isModified() || $this->aPaciente->isNew()) {
                 $affectedRows += $this->aPaciente->save($con);
             }
             $this->setPaciente($this->aPaciente);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->cargoconsultasScheduledForDeletion !== null) {
             if (!$this->cargoconsultasScheduledForDeletion->isEmpty()) {
                 CargoconsultaQuery::create()->filterByPrimaryKeys($this->cargoconsultasScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->cargoconsultasScheduledForDeletion = null;
             }
         }
         if ($this->collCargoconsultas !== null) {
             foreach ($this->collCargoconsultas as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->consultaanticiposScheduledForDeletion !== null) {
             if (!$this->consultaanticiposScheduledForDeletion->isEmpty()) {
                 ConsultaanticipoQuery::create()->filterByPrimaryKeys($this->consultaanticiposScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->consultaanticiposScheduledForDeletion = null;
             }
         }
         if ($this->collConsultaanticipos !== null) {
             foreach ($this->collConsultaanticipos as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->facturasScheduledForDeletion !== null) {
             if (!$this->facturasScheduledForDeletion->isEmpty()) {
                 FacturaQuery::create()->filterByPrimaryKeys($this->facturasScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->facturasScheduledForDeletion = null;
             }
         }
         if ($this->collFacturas !== null) {
             foreach ($this->collFacturas as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }