Beispiel #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 coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aMesa !== null) {
             if ($this->aMesa->isModified() || $this->aMesa->isNew()) {
                 $affectedRows += $this->aMesa->save($con);
             }
             $this->setMesa($this->aMesa);
         }
         if ($this->aJugador !== null) {
             if ($this->aJugador->isModified() || $this->aJugador->isNew()) {
                 $affectedRows += $this->aJugador->save($con);
             }
             $this->setJugador($this->aJugador);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->turnosScheduledForDeletion !== null) {
             if (!$this->turnosScheduledForDeletion->isEmpty()) {
                 foreach ($this->turnosScheduledForDeletion as $turno) {
                     // need to save related object because we set the relation to null
                     $turno->save($con);
                 }
                 $this->turnosScheduledForDeletion = null;
             }
         }
         if ($this->collTurnos !== null) {
             foreach ($this->collTurnos as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 public function postCadastro()
 {
     $id = Input::get('id');
     $localMesa = Input::get('localMesa');
     $nuMesa = Input::get('nuMesa');
     $qtdPessoas = Input::get('qtdPessoas');
     if (isset($id)) {
         $mesa = Mesa::find($id);
         $mesa->localMesa = $localMesa;
         $mesa->nuMesa = $nuMesa;
         $mesa->qtdPessoas = $qtdPessoas;
         $mesa->save();
     } else {
         $mesa = new Mesa();
         $mesa->localMesa = $localMesa;
         $mesa->nuMesa = $nuMesa;
         $mesa->qtdPessoas = $qtdPessoas;
         $mesa->status = 'AT';
         $mesa->save();
     }
     return Redirect::to('/mesa');
 }