Esempio n. 1
0
 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();
     $c = new Criteria();
     #$c->add(PoliticoPeer::ID, 18256, Criteria::EQUAL);
     $politicos = PoliticoPeer::doSelect($c);
     #echo SfVoUtil::myUcfirst("Casilda")."\n";die;
     foreach ($politicos as $politico) {
         $vanity = $politico->getVanity();
         $nombre = $politico->getNombre();
         $apellidos = $politico->getApellidos();
         if (strcmp($vanity, $newVanity = SfVoUtil::fixCase($vanity))) {
             echo "politico:{$vanity} -> {$newVanity}\n";
             $politico->setVanity($newVanity);
         }
         if ($nombre != ($newNombre = SfVoUtil::fixCase($nombre))) {
             echo "politico:{$nombre} -> {$newNombre}\n";
             $politico->setNombre($newNombre);
         }
         if ($apellidos != ($newApellidos = SfVoUtil::fixCase($apellidos))) {
             echo "politico:{$apellidos} -> {$newApellidos}\n";
             $politico->setApellidos($newApellidos);
         }
         $politico->save();
     }
     $instituciones = InstitucionI18nPeer::doSelect($c);
     foreach ($instituciones as $institucion) {
         $vanity = $institucion->getVanity();
         $nombreCorto = $institucion->getNombreCorto();
         $nombre = $institucion->getNombre();
         if (strcmp($vanity, $newVanity = SfVoUtil::fixCase($vanity))) {
             echo "institucion:{$vanity} -> {$newVanity}\n";
             $institucion->setVanity($newVanity);
         }
         if (strcmp($nombreCorto, $newNombreCorto = SfVoUtil::fixCase($nombreCorto))) {
             echo "institucion:{$nombreCorto} -> {$newNombreCorto}\n";
             $institucion->setNombreCorto($newNombreCorto);
         }
         if (strcmp($nombre, $newNombre = SfVoUtil::fixCase($nombre))) {
             echo "institucion:{$nombre} -> {$newNombre}\n";
             $institucion->setNombre($newNombre);
         }
         $institucion->save();
     }
     $geos = GeoPeer::doSelect($c);
     foreach ($geos as $geo) {
         $nombre = $geo->getNombre();
         if (strcmp($nombre, $newNombre = SfVoUtil::fixCase($nombre))) {
             echo "geo:{$nombre} -> {$newNombre}\n";
             $geo->setNombre($newNombre);
         }
         $geo->save();
     }
 }
Esempio n. 2
0
 public static function retrieveForAutoSelect($q, $limit)
 {
     $criteria = new Criteria();
     $criteria->add(InstitucionI18nPeer::NOMBRE, '%' . $q . '%', Criteria::LIKE);
     $criteria->addAscendingOrderByColumn(InstitucionI18nPeer::NOMBRE);
     $criteria->setLimit($limit);
     $instituciones = array();
     foreach (InstitucionI18nPeer::doSelect($criteria) as $institucion) {
         $instituciones[$institucion->getId()] = (string) $institucion->getNombre();
     }
     return $instituciones;
 }
Esempio n. 3
0
 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) {
         $vanity = $politico->getVanity();
         if ($vanity != ($new = SfVoUtil::fixVanityChars($vanity))) {
             while (preg_match("/(.*)-\$/is", $new, $m, PREG_OFFSET_CAPTURE)) {
                 $new = $m[1][0];
             }
             $c2 = new Criteria();
             $c2->add(PoliticoPeer::VANITY, "{$new}%", Criteria::LIKE);
             $c2->add(PoliticoPeer::ID, $politico->getId(), Criteria::NOT_EQUAL);
             $politicosLikeMe = PoliticoPeer::doSelect($c2);
             $counter = 0;
             foreach ($politicosLikeMe as $politicoLikeMe) {
                 $aVanity = str_replace("-", "\\-", $new);
                 if (preg_match(SfVoUtil::voDecode("/^{$new}\\-([0-9]*)\$/is"), SfVoUtil::voDecode($politicoLikeMe->getVanity()), $matches)) {
                     if ($counter < 1 + $matches[1]) {
                         $counter = 1 + $matches[1];
                     } else {
                         $counter++;
                     }
                 } else {
                     $counter++;
                 }
             }
             $new = "{$new}" . ($counter == 0 ? '' : "-{$counter}");
             echo "politico:{$vanity} ";
             echo "cambia a:{$new}\n";
             $politico->setVanity($new);
             $politico->save();
         }
     }
     $usuarios = SfGuardUserPeer::doSelect($c);
     foreach ($usuarios as $usuario) {
         $vanity = $usuario->getProfile()->getVanity();
         if ($vanity != SfVoUtil::fixVanityChars($vanity)) {
             echo "usuario:{$vanity} ({$usuario})\n";
             $usuario->getProfile()->setVanity(SfVoUtil::fixVanityChars($vanity));
             $usuario->getProfile()->save();
         }
     }
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $vanity = $partido->getAbreviatura();
         if ($vanity != SfVoUtil::fixVanityChars($vanity)) {
             echo "partido:{$vanity}\n";
         }
     }
     // Instituciones
     $instituciones = InstitucionI18nPeer::doSelect($c);
     foreach ($instituciones as $institucion) {
         $vanity = $institucion->getVanity();
         if ($vanity != ($new = SfVoUtil::fixVanityChars($vanity))) {
             echo "institucion:{$vanity}\n";
             $institucion->setVanity($new);
             $institucion->save();
             echo "cambia a:{$new}\n";
         }
     }
 }
Esempio n. 4
0
 /**
  * Retrieve object using using composite pkey values.
  * @param      int $id
  * @param      string $culture
  * @param      PropelPDO $con
  * @return     InstitucionI18n
  */
 public static function retrieveByPK($id, $culture, PropelPDO $con = null)
 {
     $key = serialize(array((string) $id, (string) $culture));
     if (null !== ($obj = InstitucionI18nPeer::getInstanceFromPool($key))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(InstitucionI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(InstitucionI18nPeer::DATABASE_NAME);
     $criteria->add(InstitucionI18nPeer::ID, $id);
     $criteria->add(InstitucionI18nPeer::CULTURE, $culture);
     $v = InstitucionI18nPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
Esempio n. 5
0
 /**
  * Gets an array of InstitucionI18n objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this Institucion has previously been saved, it will retrieve
  * related InstitucionI18ns from storage. If this Institucion is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array InstitucionI18n[]
  * @throws     PropelException
  */
 public function getInstitucionI18ns($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(InstitucionPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collInstitucionI18ns === null) {
         if ($this->isNew()) {
             $this->collInstitucionI18ns = array();
         } else {
             $criteria->add(InstitucionI18nPeer::ID, $this->id);
             InstitucionI18nPeer::addSelectColumns($criteria);
             $this->collInstitucionI18ns = InstitucionI18nPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(InstitucionI18nPeer::ID, $this->id);
             InstitucionI18nPeer::addSelectColumns($criteria);
             if (!isset($this->lastInstitucionI18nCriteria) || !$this->lastInstitucionI18nCriteria->equals($criteria)) {
                 $this->collInstitucionI18ns = InstitucionI18nPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastInstitucionI18nCriteria = $criteria;
     return $this->collInstitucionI18ns;
 }