Exemplo n.º 1
0
 private function updateSums(sfWebRequest $request)
 {
     // Actualizar cache y puntos en politicos
     if ($request->getParameter("t") == Politico::NUM_ENTITY) {
         $this->politico = PoliticoPeer::retrieveByPk($request->getParameter('e'));
         $this->politico->setSumu($this->politico->getPositives());
         $this->politico->setSumd($this->politico->getNegatives());
         if ($this->politico->isModified()) {
             PoliticoPeer::doUpdate($this->politico);
         }
         $this->clearCache($this->politico);
     } else {
         if ($request->getParameter("t") == Partido::NUM_ENTITY) {
             $this->partido = PartidoPeer::retrieveByPk($request->getParameter('e'));
             $this->partido->setSumu($this->partido->getPositives());
             $this->partido->setSumd($this->partido->getNegatives());
             if ($this->partido->isModified()) {
                 PartidoPeer::doUpdate($this->partido);
             }
             $this->clearCachePartido($this->partido);
         } else {
             if ($request->getParameter("t") == '') {
                 $review = SfReviewPeer::retrieveByPk($request->getParameter('e'));
                 if ($review->getSfReviewType()->getId() == Politico::NUM_ENTITY) {
                     $politico = PoliticoPeer::retrieveByPk($review->getEntityId());
                     $this->clearCache($politico);
                 } else {
                     if ($review->getSfReviewType()->getId() == Partido::NUM_ENTITY) {
                         $partido = PartidoPeer::retrieveByPk($review->getEntityId());
                         $this->clearCachePartido($partido);
                     }
                 }
             }
         }
     }
 }
Exemplo 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      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->aPartidoRelatedByPartidoId !== null) {
             if ($this->aPartidoRelatedByPartidoId->isModified() || $this->aPartidoRelatedByPartidoId->isNew()) {
                 $affectedRows += $this->aPartidoRelatedByPartidoId->save($con);
             }
             $this->setPartidoRelatedByPartidoId($this->aPartidoRelatedByPartidoId);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = PartidoPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = PartidoPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += PartidoPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collEnlaces !== null) {
             foreach ($this->collEnlaces as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collImagens !== null) {
             foreach ($this->collImagens as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collListas !== null) {
             foreach ($this->collListas as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collPartidosRelatedByPartidoId !== null) {
             foreach ($this->collPartidosRelatedByPartidoId as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collPartidoI18ns !== null) {
             foreach ($this->collPartidoI18ns as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collPartidoListas !== null) {
             foreach ($this->collPartidoListas as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collPropuestasRelatedByPartidoVideo1Id !== null) {
             foreach ($this->collPropuestasRelatedByPartidoVideo1Id as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collPropuestasRelatedByPartidoVideo2Id !== null) {
             foreach ($this->collPropuestasRelatedByPartidoVideo2Id as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collPoliticos !== null) {
             foreach ($this->collPoliticos as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collPromocions !== null) {
             foreach ($this->collPromocions as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collEtiquetaPartidos !== null) {
             foreach ($this->collEtiquetaPartidos as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collListaCalles !== null) {
             foreach ($this->collListaCalles as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }