Пример #1
0
 public function getCategoriaByNombre()
 {
     $table = new \apf\db\mysql5\Table($this->_table);
     $select = new \apf\db\mysql5\Select($table);
     $select->fields(array("id", "nombre"));
     $where = array(array("field" => "nombre", "value" => $this->_nombre));
     $select->where($where);
     $res = $select->execute();
     if (!sizeof($res)) {
         throw new \Exception("No se encontro la categoria " . $this->_nombre);
     }
     $this->setId($res["id"]);
 }
Пример #2
0
 public function getPaisById()
 {
     $table = new \apf\db\mysql5\Table($this->_table);
     $select = new \apf\db\mysql5\Select($table);
     $select->fields(array("id", "nombre"));
     $where = array(array("field" => "id", "value" => $this->_id));
     $select->where($where);
     $res = $select->execute($smartMode = TRUE);
     if (!$res) {
         return FALSE;
     }
     $this->setId($res["id"]);
     $this->setNombre($res["nombre"]);
 }
Пример #3
0
 public function existeUriParaOferta()
 {
     $table = new \apf\db\mysql5\Table("ofertas_uri");
     $select = new \apf\db\mysql5\Select($table);
     $fields = array("uri");
     $select->fields($fields);
     $where = array(array("field" => "uri", "value" => sprintf("%s", $this->_uri)));
     $res = $select->execute();
     if ($res) {
         return TRUE;
     }
     return FALSE;
 }
Пример #4
0
 public function existeCategoriaUsuario($id_categoria)
 {
     $table = new \apf\db\mysql5\Table("usuarios_categorias");
     $select = new \apf\db\mysql5\Select($table);
     $select->fields(array("id_usuario"));
     $where = array(array("field" => "id_usuario", "value" => $this->getId()), array("operator" => "AND"), array("field" => "id_categoria", "value" => $id_categoria));
     $select->where($where);
     $select->limit(array(1));
     $res = $select->execute();
     if (!sizeof($res)) {
         return FALSE;
     }
     return true;
 }
Пример #5
0
 public function exists()
 {
     $table = new \apf\db\mysql5\Table($this->_table);
     $select = new \apf\db\mysql5\Select($table);
     $select->fields(array("id"));
     $where = array(array("field" => "uri", "value" => $this->_uri), array("operator" => "AND"), array("field" => "categoria", "value" => $this->_categoria), array("operator" => "AND"), array("field" => "provincia", "value" => $this->_provincia));
     $select->where($where);
     $res = $select->execute();
     if ($res) {
         return TRUE;
     }
     return FALSE;
 }
Пример #6
0
 public function getLocalidadById()
 {
     $table = new \apf\db\mysql5\Table($this->_table);
     $select = new \apf\db\mysql5\Select($table);
     $select->fields(array("id", "id_provincia", "nombre"));
     $where = array(array("field" => "id", "value" => $this->_id));
     $select->where($where);
     try {
         $res = $select->execute();
         $provincia = new Provincia(NULL, $res["id_provincia"]);
         $this->setProvincia($provincia);
         $this->setId($res["id"]);
         $this->setNombre($res["nombre"]);
     } catch (\Exception $e) {
         $msg = $e->getMessage();
         throw new \Exception("No se encontro la localidad con el id " . $this->_id);
     }
 }
Пример #7
0
 public function getProvinciaById()
 {
     $table = new \apf\db\mysql5\Table($this->_table);
     $select = new \apf\db\mysql5\Select($table);
     $select->fields(array("id", "id_pais", "nombre"));
     $where = array(array("field" => "id", "value" => $this->_id));
     $select->where($where);
     try {
         $res = $select->execute();
         $pais = new Pais($res["id_pais"]);
         $this->setPais($pais);
         $this->setNombre($res["nombre"]);
     } catch (\Exception $e) {
         throw new \Exception("No se pudo encontrar la provincia con el id " . $this->_id);
     }
 }
Пример #8
0
 public function existe()
 {
     $table = new \apf\db\mysql5\Table($this->_table);
     $select = new \apf\db\mysql5\Select($table);
     $select->fields(array("id"));
     $where = array(array("field" => "nombre", "value" => $this->_nombre));
     $select->where($where);
     return $select->execute();
 }
Пример #9
0
 public function getBarrioById()
 {
     $table = new \apf\db\mysql5\Table($this->_table);
     $select = new \apf\db\mysql5\Select($table);
     $select->fields(array("id", "nombre"));
     $where = array(array("field" => "id_localidad", "value" => $this->_localidad->getId()), array("operator" => "AND"), array("field" => "id", "value" => $this->_id));
     $select->where($where);
     $res = $select->execute();
     if (!sizeof($res)) {
         throw new \Exception("No se encontro el barrio " . $this->_nombre . " para la localidad " . $this->_localidad->getNombre());
     }
     $this->setNombre($res["nombre"]);
 }