Exemple #1
0
 public function executeIndex(sfWebRequest $request)
 {
     $culture = $this->getUser()->getCulture();
     $cpos = new Criteria();
     $cpos->add(SfReviewPeer::VALUE, 1);
     $cpos->add(SfReviewPeer::IS_ACTIVE, 1);
     //$cpos->add(SfReviewPeer::CULTURE, $culture);
     $this->totalUpReviews = SfReviewPeer::doCount($cpos);
     $cneg = new Criteria();
     $cneg->add(SfReviewPeer::VALUE, -1);
     $cneg->add(SfReviewPeer::IS_ACTIVE, 1);
     //$cneg->add(SfReviewPeer::CULTURE, $culture);
     $this->totalDownReviews = SfReviewPeer::doCount($cneg);
     $exclude = "";
     $this->reviewables = EntityManager::getTopEntities(6, $exclude, "WebEntity", true);
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PoliticoPeer::SUMU);
     $c->addAscendingOrderByColumn(PoliticoPeer::SUMD);
     $c->setLimit(5);
     $this->topPoliticos = PoliticoPeer::doSelect($c);
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PartidoPeer::SUMU);
     $c->addAscendingOrderByColumn(PartidoPeer::SUMD);
     $c->setLimit(5);
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $this->partidosMasVotados = PartidoPeer::doSelect($c);
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PropuestaPeer::SUMU);
     $c->addAscendingOrderByColumn(PropuestaPeer::SUMD);
     $c->setLimit(5);
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $this->propuestasMasVotadas = PropuestaPeer::doSelect($c);
     //Totales
     /*
     $c = new Criteria();
     $this->totalPoliticos = PoliticoPeer::doCount($c);
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $this->totalPartidos = PartidoPeer::doCount($c);
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $this->totalPropuestas = PropuestaPeer::doCount($c);
     */
     $this->response->addMeta('Description', sfContext::getInstance()->getI18N()->__('Comparte opiniones sobre políticos y partidos de España. Ranking de los políticos y partidos más votados.'));
     // Ultimos comentarios
     $filter = array();
     $filter['culture'] = $culture;
     //$this->topReviews = SfReviewManager::getReviews($filter, 1, 5);
     $this->activities = SfReviewManager::getActivities($filter, 1, 5);
     // elecciones destacadas
     $convocatoriaActiva = sfConfig::get('sf_convocatoria_activa');
     $this->convocatoria = ConvocatoriaPeer::retrieveByPk($convocatoriaActiva);
 }
Exemple #2
0
 public function executeFilter(sfWebRequest $request)
 {
     $culture = $this->getUser()->getCulture();
     $q = $request->getParameter("q");
     $c = new Criteria();
     $c->addJoin(PartidoPeer::ID, PartidoI18nPeer::ID);
     $c->add(PartidoI18nPeer::CULTURE, $culture);
     $rCriterion = $c->getNewCriterion(PartidoPeer::ABREVIATURA, "%{$q}%", Criteria::LIKE);
     $rCriterion->addOr($c->getNewCriterion(PartidoI18nPeer::NOMBRE, "%{$q}%", Criteria::LIKE));
     $c->add($rCriterion);
     $c->setLimit(20);
     $this->partidos = PartidoPeer::doSelect($c);
 }
 private function partido($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(PartidoPeer::ID, $options['minid'], Criteria::GREATER_EQUAL);
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         if ($partido->getImagen() != '') {
             echo "Creating " . $partido->getImagen() . " ...\n";
             $s3->createPartidoFromOri($partido->getImagen());
         }
     }
 }
Exemple #4
0
 public function executeAcPartido(sfWebRequest $request)
 {
     $culture = $this->getUser()->getCulture();
     $term = $request->getParameter('term');
     $c = new Criteria();
     $c->setLimit(20);
     $c->addJoin(array(PartidoPeer::ID, PartidoI18nPeer::CULTURE), array(PartidoI18nPeer::ID, "'{$culture}'"), Criteria::INNER_JOIN);
     $rCriterion = $c->getNewCriterion(PartidoPeer::ABREVIATURA, "%{$term}%", Criteria::LIKE);
     $rCriterion->addOr($c->getNewCriterion(PartidoI18nPeer::NOMBRE, "%{$term}%", Criteria::LIKE));
     $c->add($rCriterion);
     $partidos = PartidoPeer::doSelect($c);
     $res = '[';
     $idx = 0;
     foreach ($partidos as $partido) {
         $idx++;
         $res .= ($idx > 1 ? ',' : '') . '{"id": "' . $partido->getAbreviatura() . '", "value": "' . $partido->getAbreviatura() . ', ' . $partido->getNombre() . '"}';
     }
     $res .= ']';
     $response = $this->getResponse();
     $response->setContentType('application/json');
     echo $res;
     die;
 }
 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";
         }
     }
 }
Exemple #6
0
 protected function execute($arguments = array(), $options = array())
 {
     $sfContext = sfContext::createInstance($this->configuration);
     $controller = $sfContext->getController();
     $this->cultures = array('ca' => 'cat', 'es' => 'es');
     $culture = $options['culture'];
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     //foreach($this->cultures as $culture => $ext){
     $sfContext->getUser()->setCulture($culture);
     // **************** HOME **********************
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@homepage", true), $culture);
     // **************** Ultimas opiniones **********************
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_politicos_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_partidos_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_propuestas_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_otras_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_politicos_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_partidos_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_propuestas_feed_{$culture}", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@ultimas_opiniones_otras_feed_{$culture}", true), $culture);
     // **************** varias **********************
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@about", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@rules", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@search", true), $culture);
     $this->writeToSitemap("voota-{$culture}", $controller->genUrl("@contact", true), $culture);
     // **************** Fichas POLITICOS **********************
     $c = new Criteria();
     //$c->setLimit(5);
     $politicos = PoliticoPeer::doSelect($c);
     foreach ($politicos as $politico) {
         $this->writeToSitemap("politico-{$culture}", $controller->genUrl("politico/show?id=" . $politico->getVanity(), true), $culture);
     }
     // **************** Fichas PARTIDOS **********************
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $this->writeToSitemap("partido-{$culture}", $controller->genUrl("partido/show?id=" . $partido->getAbreviatura(), true), $culture);
     }
     // **************** Fichas PROPUESTAS **********************
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $propuestas = PropuestaPeer::doSelect($c);
     foreach ($propuestas as $propuesta) {
         $this->writeToSitemap("propuesta-{$culture}", $controller->genUrl("propuesta/show?id=" . $propuesta->getVanity(), true), $culture);
     }
     // **************** Fichas USUARIOS **********************
     $c = new Criteria();
     $c->add(SfGuardUserPeer::IS_ACTIVE, true);
     $usuarios = SfGuardUserPeer::doSelect($c);
     foreach ($usuarios as $usuario) {
         $this->writeToSitemap("usuario-{$culture}", $controller->genUrl("perfil/show?username="******"politico-feed-{$culture}", $controller->genUrl("politico/show?id=" . $politico->getVanity(), true), $culture);
     }
     // **************** feeds PARTIDOS **********************
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $this->writeToSitemap("partido-feed-{$culture}", $controller->genUrl("partido/feed?id=" . $partido->getAbreviatura(), true), $culture);
     }
     // **************** feeds PROPUESTAS **********************
     $c = new Criteria();
     $c->add(PropuestaPeer::IS_ACTIVE, true);
     $c->add(PropuestaPeer::CULTURE, $culture);
     $propuestas = PropuestaPeer::doSelect($c);
     foreach ($propuestas as $propuesta) {
         $this->writeToSitemap("propuesta-feed-{$culture}", $controller->genUrl("propuesta/feed?id=" . $propuesta->getVanity(), true), $culture);
     }
     // **************** feeds USUARIOS **********************
     $c = new Criteria();
     $c->add(SfGuardUserPeer::IS_ACTIVE, true);
     $usuarios = SfGuardUserPeer::doSelect($c);
     foreach ($usuarios as $usuario) {
         $this->writeToSitemap("usuario-feed-{$culture}", $controller->genUrl("perfil/feed?username="******"propuesta-ranking-{$culture}", $controller->genUrl("propuesta/ranking", true), $culture);
     $pager = EntityManager::getPropuestas($culture);
     $idx = 1;
     while ($idx < $pager->getLastPage()) {
         $idx++;
         $this->writeToSitemap("propuesta-ranking-{$culture}", $controller->genUrl("propuesta/ranking?page={$idx}", true), $culture);
     }
     // **************** ranking POLITICOS **********************
     $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking", true), $culture);
     $pager = EntityManager::getPoliticos(false, false, $culture);
     $idx = 1;
     while ($idx < $pager->getLastPage()) {
         $idx++;
         $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?page={$idx}", true), $culture);
     }
     # ranking de polis filtrados por partido
     $c = new Criteria();
     $c->add(PartidoPeer::IS_ACTIVE, true);
     $partidos = PartidoPeer::doSelect($c);
     foreach ($partidos as $partido) {
         $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura(), true), $culture);
         $pager = EntityManager::getPoliticos($partido->getAbreviatura(), false, $culture);
         $idx = 1;
         while ($idx < $pager->getLastPage()) {
             $idx++;
             $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura() . "&page={$idx}", true), $culture);
         }
         # ranking de polis filtrados por partido e insti
         $c = new Criteria();
         $c->add(InstitucionPeer::IS_ACTIVE, true);
         $c->addJoin(PoliticoInstitucionPeer::INSTITUCION_ID, InstitucionPeer::ID);
         $c->addJoin(PoliticoPeer::ID, PoliticoInstitucionPeer::POLITICO_ID);
         $c->add(PoliticoPeer::PARTIDO_ID, $partido->getId());
         $instis = InstitucionPeer::doSelect($c);
         foreach ($instis as $insti) {
             $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura() . "&institucion=" . $insti->getVanity(), true), $culture);
             $pager = EntityManager::getPoliticos($partido->getAbreviatura(), $insti->getVanity(), $culture);
             $idx = 1;
             while ($idx < $pager->getLastPage()) {
                 $idx++;
                 $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=" . $partido->getAbreviatura() . "&institucion=" . $insti->getVanity() . "&page={$idx}", true), $culture);
             }
         }
     }
     # ranking de polis filtrados por insti
     $c = new Criteria();
     $c->add(InstitucionPeer::IS_ACTIVE, true);
     $instis = InstitucionPeer::doSelect($c);
     foreach ($instis as $insti) {
         $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=all&institucion=" . $insti->getVanity(), true), $culture);
         $pager = EntityManager::getPoliticos(false, $insti->getVanity(), $culture);
         $idx = 1;
         while ($idx < $pager->getLastPage()) {
             $idx++;
             $this->writeToSitemap("politico-ranking-{$culture}", $controller->genUrl("politico/ranking?partido=all&institucion=" . $insti->getVanity() . "&page={$idx}", true), $culture);
         }
     }
     // **************** ranking PARTIDOS **********************
     $this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking", true), $culture);
     $pager = EntityManager::getPartidos(false, $culture);
     $idx = 1;
     while ($idx < $pager->getLastPage()) {
         $idx++;
         $this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking?page={$idx}", true), $culture);
     }
     $c = new Criteria();
     $c->add(InstitucionPeer::IS_ACTIVE, true);
     $instis = InstitucionPeer::doSelect($c);
     foreach ($instis as $insti) {
         $this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking?institucion=" . $insti->getVanity(), true), $culture);
         $pager = EntityManager::getPartidos($insti->getVanity(), $culture);
         $idx = 1;
         while ($idx < $pager->getLastPage()) {
             $idx++;
             $this->writeToSitemap("partido-ranking-{$culture}", $controller->genUrl("partido/ranking?institucion=" . $insti->getVanity() . "&page={$idx}", true), $culture);
         }
     }
     // **************** elecciones **********************
     $c = new Criteria();
     $convocatorias = ConvocatoriaPeer::doSelect($c);
     foreach ($convocatorias as $convocatoria) {
         $this->writeToSitemap("elecciones-{$culture}", $controller->genUrl('eleccion/show?vanity=' . $convocatoria->getEleccion()->getVanity() . '&convocatoria=' . $convocatoria->getNombre(), true), $culture);
         $used = array();
         foreach ($convocatoria->getListasJoinCircunscripcion() as $geoLista) {
             if (!in_array($geoLista->getCircunscripcion()->getGeo(), $used)) {
                 $used[] = $geoLista->getCircunscripcion()->getGeo();
                 $this->writeToSitemap("elecciones-{$culture}", $controller->genUrl('eleccion/show?geo=' . $geoLista->getCircunscripcion()->getGeo()->getNombre() . '&vanity=' . $convocatoria->getEleccion()->getVanity() . '&convocatoria=' . $convocatoria->getNombre(), true), $culture);
             }
             $this->writeToSitemap("elecciones-{$culture}", $controller->genUrl('lista/show?partido=' . $geoLista->getPartido()->getAbreviatura() . '&geo=' . $geoLista->getCircunscripcion()->getGeo()->getNombre() . '&vanity=' . $convocatoria->getEleccion()->getVanity() . '&convocatoria=' . $convocatoria->getNombre(), true), $culture);
         }
     }
     //}
     $this->closeAll($culture);
 }
Exemple #7
0
 public function getResults($geoName = false, $sorted = true)
 {
     $aKey = "Convocatoria_" . $this->getId() . "-{$geoName}-{$sorted}";
     $cache = sfcontext::getInstance()->getViewCacheManager() ? sfcontext::getInstance()->getViewCacheManager()->getCache() : false;
     if ($cache) {
         $key = md5($aKey);
         $data = unserialize($cache->get($key));
     } else {
         $data = false;
     }
     if (!$data) {
         $res = array();
         $c = new Criteria();
         $c->addJoin(ListaPeer::PARTIDO_ID, PartidoPeer::ID);
         $c->add(ListaPeer::CONVOCATORIA_ID, $this->getId());
         $c->setDistinct();
         $res['partidos'] = PartidoPeer::doSelect($c);
         // Circus
         $c = new Criteria();
         $c->addJoin(ListaPeer::CIRCUNSCRIPCION_ID, CircunscripcionPeer::ID);
         $c->addJoin(CircunscripcionPeer::GEO_ID, GeoPeer::ID);
         $c->add(ListaPeer::CONVOCATORIA_ID, $this->getId());
         $c->addAscendingOrderByColumn(GeoPeer::NOMBRE);
         $c->setDistinct();
         //$this->geos = GeoPeer::doSelect( $c );
         $res['circus'] = CircunscripcionPeer::doSelect($c);
         $instituciones = $this->getEleccion()->getEleccionInstitucions();
         //$this->institucionName = $instituciones[0]->getInstitucion();
         $res['institucionName'] = $instituciones[0]->getInstitucion();
         // Minimo de votos necesario para obtener escaño
         $listas = $this->getListas();
         if ($geoName) {
             $c = new Criteria();
             $c->addJoin(ListaPeer::CIRCUNSCRIPCION_ID, CircunscripcionPeer::ID);
             $c->addJoin(CircunscripcionPeer::GEO_ID, GeoPeer::ID);
             $c->add(ListaPeer::CONVOCATORIA_ID, $this->getId());
             $c->add(GeoPeer::NOMBRE, $geoName);
             //$this->geos = GeoPeer::doSelect( $c );
             $circu = CircunscripcionPeer::doSelectOne($c);
             $numEscanyos = $circu->getEscanyos();
         } else {
             $numEscanyos = 0;
             $circuCounted = array();
             foreach ($listas as $lista) {
                 if (!in_array($lista->getCircunscripcion()->getId(), $circuCounted)) {
                     $circuCounted[] = $lista->getCircunscripcion()->getId();
                     $numEscanyos += $lista->getCircunscripcion()->getEscanyos();
                 }
             }
         }
         $listaElectoral = ListaElectoral::getInstance($this->getId(), false, $geoName);
         $politicos = $listaElectoral->getPoliticos();
         $idx = 0;
         //$this->minSumu = 0;
         $res['minSumu'] = 0;
         //$this->minSumd = 0;
         $res['minSumd'] = 0;
         $res['lastDate'] = null;
         $res['apellidos'] = '';
         $res['nombre'] = '';
         foreach ($politicos as $politico) {
             $idx++;
             if ($idx == $numEscanyos + 1) {
                 $res['minSumu'] = $politico->getSumu();
                 $res['minSumd'] = $politico->getSumd();
                 $res['lastDate'] = $politico->getLastDate();
                 $res['apellidos'] = $politico->getApellidos();
                 $res['nombre'] = $politico->getNombre();
             }
         }
         // Ordenar por escaños
         if ($sorted) {
             $idx = 0;
             $res['totalEscanyos'] = 0;
             foreach ($res['partidos'] as $partido) {
                 $listaElectoral = new ListaElectoral($this->getId(), $partido->getId(), $geoName);
                 $escanyos = $listaElectoral->getEscanyos($res['minSumu'], $res['minSumd'], $res['lastDate'], $res['apellidos']);
                 $res['totalEscanyos'] += $escanyos;
                 for ($j = 0; $j < $idx; $j++) {
                     $listaElectoral2 = ListaElectoral::getInstance($this->getId(), $res['partidos'][$j]->getId(), $geoName);
                     if ($listaElectoral2->getEscanyos($res['minSumu'], $res['minSumd'], $res['lastDate'], $res['apellidos']) < $escanyos) {
                         $partidoTmp = clone $res['partidos'][$idx];
                         $res['partidos'][$idx] = $res['partidos'][$j];
                         $res['partidos'][$j] = $partidoTmp;
                     }
                 }
                 $idx++;
             }
         }
         $data = $res;
         if ($cache) {
             $n = rand(0, 100);
             $cache->set($key, serialize($data ? $data : "zero"), 3600 * $n / 100);
         }
     }
     return $data == "zero" ? 0 : $data;
 }
Exemple #8
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(PartidoPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(PartidoPeer::DATABASE_NAME);
         $criteria->add(PartidoPeer::ID, $pks, Criteria::IN);
         $objs = PartidoPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemple #9
0
 /**
  * Gets an array of Partido 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 Partido has previously been saved, it will retrieve
  * related PartidosRelatedByPartidoId from storage. If this Partido 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 Partido[]
  * @throws     PropelException
  */
 public function getPartidosRelatedByPartidoId($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(PartidoPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collPartidosRelatedByPartidoId === null) {
         if ($this->isNew()) {
             $this->collPartidosRelatedByPartidoId = array();
         } else {
             $criteria->add(PartidoPeer::PARTIDO_ID, $this->id);
             PartidoPeer::addSelectColumns($criteria);
             $this->collPartidosRelatedByPartidoId = PartidoPeer::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(PartidoPeer::PARTIDO_ID, $this->id);
             PartidoPeer::addSelectColumns($criteria);
             if (!isset($this->lastPartidoRelatedByPartidoIdCriteria) || !$this->lastPartidoRelatedByPartidoIdCriteria->equals($criteria)) {
                 $this->collPartidosRelatedByPartidoId = PartidoPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastPartidoRelatedByPartidoIdCriteria = $criteria;
     return $this->collPartidosRelatedByPartidoId;
 }