public static function getCampoCodAgencia() { $c = TablaPeer::getCriterioAlcance(); $id_empresa = sfContext::getInstance()->getUser()->getAttribute('idempresa', 0); $c->AddJoin(CampoPeer::ID_CAMPO, RelCampoTablaPeer::ID_CAMPO, Criteria::JOIN); $c->AddJoin(RelCampoTablaPeer::ID_TABLA, TablaPeer::ID_TABLA, Criteria::JOIN); $c->addAnd(TablaPeer::ID_EMPRESA, $id_empresa, Criteria::EQUAL); $c->addAnd(TablaPeer::ES_FICHEROS, true, Criteria::EQUAL); $c->addAnd(CampoPeer::ES_COD_AGENCIA, true, Criteria::EQUAL); $campo = CampoPeer::doSelectOne($c); if ($campo instanceof Campo) { return $campo->getIdCampo(); } else { return 0; } }
/** * Get the associated Campo object * * @param PropelPDO Optional Connection object. * @return Campo The associated Campo object. * @throws PropelException */ public function getCampo(PropelPDO $con = null) { if ($this->aCampo === null && $this->id_campo !== null) { $c = new Criteria(CampoPeer::DATABASE_NAME); $c->add(CampoPeer::ID_CAMPO, $this->id_campo); $this->aCampo = CampoPeer::doSelectOne($c, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aCampo->addTareas($this); */ } return $this->aCampo; }
protected function getCampoOr404($id_campo = 'id_campo') { if (!$this->getRequestParameter($id_campo)) { $this->forward404(); } else { $c = $this->getCriterio(); $c->addAnd(CampoPeer::ID_CAMPO, $this->getRequestParameter($id_campo)); $campo = CampoPeer::doSelectOne($c); $this->forward404Unless($campo); } return $campo; }