Exemplo n.º 1
0
 public function getCidadesPorEstado($id_estado)
 {
     $id_estado = (int) $id_estado;
     $cidades = $this->dao->get("estado_id = {$id_estado}");
     $lista = array();
     foreach ($cidades as $cidade) {
         $lista[] = $this->setDTO($cidade)->getArrayDados();
     }
     return $lista;
 }
Exemplo n.º 2
0
function optCidades($estado = 'ES', $cidade = null, $sufixoUf = false)
{
    $html = "";
    if ($cidade == null) {
        $cidade = -1;
    }
    $dCidades = new CidadesDAO();
    foreach ($dCidades->lista("WHERE (estado.id = :estado OR estado.uf = :estado) ORDER BY a.title ASC", array('estado' => $estado)) as $v) {
        if ($cidade != -1 and ($cidade == $v->getId() or strtolower($v->getTitle()) == strtolower($cidade))) {
            $selected = true;
        } else {
            $selected = false;
        }
        $title = $v->getTitle();
        if ($sufixoUf) {
            $title .= '/' . $v->getUf();
        }
        $html .= formSelectOption($title, $v->getId(), $selected);
    }
    return $html;
}