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->aMlbTeamRef !== null) {
             if ($this->aMlbTeamRef->isModified() || $this->aMlbTeamRef->isNew()) {
                 $affectedRows += $this->aMlbTeamRef->save($con);
             }
             $this->setMlbTeamRef($this->aMlbTeamRef);
         }
         if ($this->aCardRef !== null) {
             if ($this->aCardRef->isModified() || $this->aCardRef->isNew()) {
                 $affectedRows += $this->aCardRef->save($con);
             }
             $this->setCardRef($this->aCardRef);
         }
         if ($this->aDivisionRef !== null) {
             if ($this->aDivisionRef->isModified() || $this->aDivisionRef->isNew()) {
                 $affectedRows += $this->aDivisionRef->save($con);
             }
             $this->setDivisionRef($this->aDivisionRef);
         }
         if ($this->aPositionRef !== null) {
             if ($this->aPositionRef->isModified() || $this->aPositionRef->isNew()) {
                 $affectedRows += $this->aPositionRef->save($con);
             }
             $this->setPositionRef($this->aPositionRef);
         }
         if ($this->aTeams !== null) {
             if ($this->aTeams->isModified() || $this->aTeams->isNew()) {
                 $affectedRows += $this->aTeams->save($con);
             }
             $this->setTeams($this->aTeams);
         }
         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->aDivisionRef !== null) {
             if ($this->aDivisionRef->isModified() || $this->aDivisionRef->isNew()) {
                 $affectedRows += $this->aDivisionRef->save($con);
             }
             $this->setDivisionRef($this->aDivisionRef);
         }
         if ($this->aLeagueRef !== null) {
             if ($this->aLeagueRef->isModified() || $this->aLeagueRef->isNew()) {
                 $affectedRows += $this->aLeagueRef->save($con);
             }
             $this->setLeagueRef($this->aLeagueRef);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->playerssScheduledForDeletion !== null) {
             if (!$this->playerssScheduledForDeletion->isEmpty()) {
                 foreach ($this->playerssScheduledForDeletion as $players) {
                     // need to save related object because we set the relation to null
                     $players->save($con);
                 }
                 $this->playerssScheduledForDeletion = null;
             }
         }
         if ($this->collPlayerss !== null) {
             foreach ($this->collPlayerss as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }