protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $s3 = new S3Voota(); $c = new Criteria(); //$c->add(PoliticoPeer::ID, 1, Criteria::EQUAL); $politicos = PoliticoPeer::doSelect($c); foreach ($politicos as $politico) { if ($politico->getImagen() != '') { echo "Fixing " . $politico->getId() . " ...\n"; $bio = $politico->getBio(); if (preg_match("/<li class=\"correo_dip\">(.*)>(.*)<(.*)<\\/li>/", $bio)) { $bio = preg_replace("/</", '<', $bio); $bio = preg_replace("/>/", '>', $bio); } if (preg_match("/<li class=\"correo_dip\">(.*)>(.*)<(.*)<\\/li>/", $bio, $regs)) { $bio = preg_replace("/<li class=\"correo_dip\">(.*)>(.*)<(.*)<\\/li>/", '', $bio); $email = $regs[2]; } $bio = strip_tags($bio); $bio = preg_replace("/[ ]+/", ' ', $bio); $bio = preg_replace("/[ ]+/", ' ', $bio); if ($politico->getEmail() == '' && $email != '') { //echo "Cambiando email\n"; $politico->setEmail($email); } $politico->setBio($bio); if ($politico->isModified()) { PoliticoPeer::doUpdate($politico); } } } }
/** * 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->asfGuardUser !== null) { if ($this->asfGuardUser->isModified() || $this->asfGuardUser->isNew()) { $affectedRows += $this->asfGuardUser->save($con); } $this->setsfGuardUser($this->asfGuardUser); } if ($this->aPartido !== null) { if ($this->aPartido->isModified() || $this->aPartido->isNew()) { $affectedRows += $this->aPartido->save($con); } $this->setPartido($this->aPartido); } if ($this->isNew()) { $this->modifiedColumns[] = PoliticoPeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = PoliticoPeer::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 += PoliticoPeer::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->collPoliticoI18ns !== null) { foreach ($this->collPoliticoI18ns as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collPoliticoInstitucions !== null) { foreach ($this->collPoliticoInstitucions as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collPoliticoListas !== null) { foreach ($this->collPoliticoListas 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->collEtiquetaPoliticos !== null) { foreach ($this->collEtiquetaPoliticos 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; }
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); } } } } } }