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"]); }
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"]); }
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; }
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; }
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; }
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); } }
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); } }
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(); }
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"]); }