/** * Declares an association between this object and a Lista object. * * @param Lista $v * @return PartidoLista The current object (for fluent API support) * @throws PropelException */ public function setLista(Lista $v = null) { if ($v === null) { $this->setListaId(NULL); } else { $this->setListaId($v->getId()); } $this->aLista = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Lista object, it will not be re-added. if ($v !== null) { $v->addPartidoLista($this); } return $this; }
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(); $handle = fopen("php://stdin", "r"); $line = fgets($handle); while ($line = fgets($handle)) { $data = explode(";", "{$line}"); $c = new Criteria(); $c->add(PartidoPeer::ABREVIATURA, $data[5]); $partido = PartidoPeer::doSelectOne($c); if (!$partido) { echo "Not found: (" . $data[5] . ")\n"; continue; } $circu = CircunscripcionPeer::retrieveByPK($data[4]); $convocatoria = ConvocatoriaPeer::retrieveByPK($data[3]); $c = new Criteria(); $c->add(ListaPeer::CONVOCATORIA_ID, $data[3]); $c->add(ListaPeer::CIRCUNSCRIPCION_ID, $data[4]); $c->add(ListaPeer::PARTIDO_ID, $partido->getId()); $lista = ListaPeer::doSelectOne($c); if (!$lista) { $lista = new Lista(); $lista->setPartido($partido); $lista->setCircunscripcion($circu); $lista->setConvocatoria($convocatoria); $lista->save(); echo "Created lista ({$partido}, {$circu})\n"; } $politicos = false; $c = new Criteria(); $c->add("concat(nombre, ' ', apellidos)", trim($data[2])); //$c->add('fullname', utf8_encode( trim($data[2]) ), Criteria::EQUAL); $politicos = PoliticoPeer::doSelect($c); if (count($politicos) != 0) { echo "(ASIGNADO) " . $data[2] . "\n"; $politico = $politicos[0]; } else { echo "(NUEVO) " . $data[2] . "\n"; $politico = new Politico(); $nombreApellidos = explode(" ", $data[2]); $nombre = array_shift($nombreApellidos); $apellidos = implode(" ", $nombreApellidos); $politico->setNombre($nombre); $politico->setApellidos($apellidos); if ($data[7] != '1') { if (count($data) > 10 && trim($data[10]) != '') { $c = new Criteria(); $c->add(PartidoPeer::ABREVIATURA, $data[5]); $partido = PartidoPeer::doSelectOne($c); if ($partido) { $politico->setPartido($partido); } } else { $politico->setPartido($lista->getPartido()); } } if ($data[1] && trim($data[1]) != '') { $politico->setSexo($data[1] == "hombre" ? 'H' : 'M'); } $politico->save(); $politicoI18n = new PoliticoI18n(); $politicoI18n->setPolitico($politico); $politicoI18n->setCulture('es'); $politicoI18n->save(); $politicoI18n = new PoliticoI18n(); $politicoI18n->setPolitico($politico); $politicoI18n->setCulture('ca'); $politicoI18n->save(); } $c = new Criteria(); $c->add(PoliticoListaPeer::LISTA_ID, $lista->getId()); $c->add(PoliticoListaPeer::POLITICO_ID, $politico->getId()); $pl = PoliticoListaPeer::doSelectOne($c); if (!$pl) { $pl = new PoliticoLista(); $pl->setLista($lista); $pl->setPolitico($politico); } else { echo "Ya estaba.\n"; } if ($data[6] != '1') { $pl->setOrden($data[0]); } $pl->save(); //echo $data[2]; } fclose($handle); }
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(); $handle = fopen("php://stdin", "r"); $line = fgets($handle); while ($line = fgets($handle)) { $data = explode(";", "{$line}"); $c = new Criteria(); $c->add(GeoPeer::NOMBRE, $data[3]); $geos = GeoPeer::doSelect($c); $aGeo = false; foreach ($geos as $geo) { if ($geo->getGeoRelatedByGeoId() != null && $geo->getGeoRelatedByGeoId()->getCodigo() && $geo->getGeoRelatedByGeoId()->getCodigo() != '') { //echo 'geo: ' . $geo->getNombre() . "\n"; $aGeo = $geo; } } if (!$aGeo) { echo 'Geo not found: (' . $data[3] . ")\n"; continue; } $c = new Criteria(); $c->add(PartidoPeer::ABREVIATURA, $data[5]); $partido = PartidoPeer::doSelectOne($c); if (!$partido) { $partido = new Partido(); $partido->setAbreviatura($data[5]); $partido->setIsActive(true); $partido->setNombre($data[5], 'es'); $partido->setNombre($data[5], 'ca'); $partido->save(); echo "Created partido ({$partido})\n"; } $c = new Criteria(); $c->add(CircunscripcionPeer::GEO_ID, $aGeo->getId()); $circu = CircunscripcionPeer::doSelectOne($c); $c = new Criteria(); $c->addJoin(ConvocatoriaPeer::ELECCION_ID, EleccionPeer::ID); $c->addJoin(EleccionInstitucionPeer::ELECCION_ID, EleccionPeer::ID); $c->addJoin(InstitucionPeer::ID, EleccionInstitucionPeer::INSTITUCION_ID); $c->add(InstitucionPeer::GEO_ID, $aGeo->getId()); $convocatoria = ConvocatoriaPeer::doSelectOne($c); if (!$convocatoria) { echo "Convocatoria not found: ({$geo})\n"; continue; } $c = new Criteria(); $c->add(ListaPeer::CONVOCATORIA_ID, $convocatoria->getId()); $c->add(ListaPeer::CIRCUNSCRIPCION_ID, $circu->getId()); $c->add(ListaPeer::PARTIDO_ID, $partido->getId()); $lista = ListaPeer::doSelectOne($c); if (!$lista) { $lista = new Lista(); $lista->setPartido($partido); $lista->setCircunscripcion($circu); $lista->setConvocatoria($convocatoria); $lista->save(); echo "Created lista ({$partido}, {$circu})\n"; } $politicos = false; $c = new Criteria(); $c->add("concat(nombre, ' ', apellidos)", trim($data[2])); //$c->add('fullname', utf8_encode( trim($data[2]) ), Criteria::EQUAL); $politicos = PoliticoPeer::doSelect($c); if (count($politicos) != 0) { echo "(ASIGNADO) " . $data[2] . "\n"; $politico = $politicos[0]; } else { echo "(NUEVO) " . $data[2] . "\n"; $politico = new Politico(); $nombreApellidos = explode(" ", $data[2]); $nombre = array_shift($nombreApellidos); $apellidos = implode(" ", $nombreApellidos); $politico->setNombre($nombre); $politico->setApellidos($apellidos); if ($data[7] != '1') { if (trim($data[10]) != '') { $c = new Criteria(); $c->add(PartidoPeer::ABREVIATURA, $data[5]); $partido = PartidoPeer::doSelectOne($c); if ($partido) { $politico->setPartido($partido); } } else { $politico->setPartido($lista->getPartido()); } } $politico->setSexo($data[1] == "hombre" ? 'H' : 'M'); $politico->save(); $politicoI18n = new PoliticoI18n(); $politicoI18n->setPolitico($politico); $politicoI18n->setCulture('es'); $politicoI18n->save(); $politicoI18n = new PoliticoI18n(); $politicoI18n->setPolitico($politico); $politicoI18n->setCulture('ca'); $politicoI18n->save(); } $c = new Criteria(); $c->add(PoliticoListaPeer::LISTA_ID, $lista->getId()); $c->add(PoliticoListaPeer::POLITICO_ID, $politico->getId()); $pl = PoliticoListaPeer::doSelectOne($c); if (!$pl) { $pl = new PoliticoLista(); $pl->setLista($lista); $pl->setPolitico($politico); } else { echo "Ya estaba.\n"; } $pl->setOrden($data[0]); $pl->save(); } fclose($handle); }
/** * Filter the query by a related Lista object * * @param Lista|PropelCollection $lista The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return Lista_audiolibroQuery The current query, for fluid interface */ public function filterByLista($lista, $comparison = null) { if ($lista instanceof Lista) { return $this->addUsingAlias(Lista_audiolibroPeer::ID_LISTA, $lista->getId(), $comparison); } elseif ($lista instanceof PropelCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(Lista_audiolibroPeer::ID_LISTA, $lista->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByLista() only accepts arguments of type Lista or PropelCollection'); } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Lista $value A Lista object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Lista $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Exclude object from result * * @param Lista $lista Object to remove from the list of results * * @return ListaQuery The current query, for fluid interface */ public function prune($lista = null) { if ($lista) { $this->addUsingAlias(ListaPeer::ID, $lista->getId(), Criteria::NOT_EQUAL); } return $this; }
<?php include_once '../../includes.sys/ini.php'; include_once '../../includes.sys/metodos.php'; include_once '../DAO/CadastroDAO.php'; include_once '../Cadastro.class.php'; checkUserAuth(EXTERNAL_ROOT_PORTAL . '/index.php?error=true'); include_once '../../head.php'; $lista = new Lista(); $DAO = new ListaDAO(); $lista->setId(limpaTexto($_GET['id'])); //Pegando o nome do projeto $retorno = $DAO->Listar("SELECT A.titulo,\r\n\t\t \t\t\t\t\t\tA.numero,\r\n\t\t\t\t\t\t\t\tB.nome AS cod_projeto,\r\n\t\t\t\t\t\t\t\tC.nome AS nucleo,\r\n\t\t\t\t\t\t\t\tD.nome AS contrato,\r\n\t\t\t\t\t\t\t\tE.nome AS obra,\r\n\t\t\t\t\t\t\t\tF.nome AS trecho,\r\n\t\t\t\t\t\t\t\tG.nome AS fase,\r\n\t\t\t\t\t\t\t\tH.nome AS disciplina,\r\n\t\t\t\t\t\t\t\tI.nome AS tipo_documento,\r\n\t\t\t\t\t\t\t\tJ.nome AS empresa\r\n\t\t\t\t\t\t\tFROM tb_projeto_cad A\r\n\t\t\t\t\t\t\tINNER JOIN tb_cod_projeto B \t\tON A.id_cod_projeto = B.id\r\n\t\t\t\t\t\t\tINNER JOIN tb_nucleo C \t\t\t\tON A.id_nucleo = C.id\r\n\t\t\t\t\t\t\tINNER JOIN tb_projeto_contrato D \tON A.id_contrato = D.id\r\n\t\t\t\t\t\t\tINNER JOIN tb_projeto_obra E \t\tON A.id_obra = E.id\r\n\t\t\t\t\t\t\tINNER JOIN tb_projeto_trecho F \t\tON A.id_trecho = F.id\r\n\t\t\t\t\t\t\tINNER JOIN tb_fase_projeto G \t\tON A.id_fase = G.id\r\n\t\t\t\t\t\t\tINNER JOIN tb_disciplina H\t\t\tON A.id_disciplina = H.id\r\n\t\t\t\t\t\t\tINNER JOIN tb_tipo_documento I \t\tON A.id_tipo_doc = I.id\r\n\t\t\t\t\t\t\tINNER JOIN tb_empresa J\t\t \t\tON A.id_empresa = J.id\r\n\t\t\t\t\t\t\tWHERE A.id=" . $lista->getId()); foreach ($retorno as $item) { $lista->setTitulo($item['titulo']); $lista->setSequencial($item['numero']); $lista->setEmpresa($item['empresa']); $lista->setCodProjeto($item['cod_projeto']); $lista->setNucleo($item['nucleo']); $lista->setContrato($item['contrato']); $lista->setObra($item['obra']); $lista->setTrecho($item['trecho']); $lista->setFaseDoProjeto($item['fase']); $lista->setDisciplina($item['disciplina']); $lista->setTipoDeDocumento($item['tipo_documento']); $lista->setEmpresa($item['empresa']); } ?> <!-- topbar ends --> <div class="container-fluid"> <div class="row-fluid">