/** * @param ConexaoLink $Link (opcional) é a um parametro opcional do link, use somente * quando você já estiver aberto uma conexão, caso não tenha aberto a classe irá * automaticamente abrir * @param int $Paginacao (opcional) limite de linhas por página */ public function __construct($Link = null) { $this->ConexaoLink = $Link; if ($this->ConexaoLink == null) { $this->Parent = true; $this->ConexaoLink = parent::open(); } }
public function clientesfake() { $banco = "oo_laravel"; $conn = Conexao::open($banco); $sql = 'SELECT * FROM oo_laravel.clientes'; $stmt = $conn->query($sql); $result = $stmt->fetchall(\PDO::FETCH_OBJ); $conn = null; unset($conn); return $result; }
function loadAreasTematicas() { $minhaConexao = new Conexao(); $con = $minhaConexao->open(); $sql = "SELECT ri.id as id, ri.nome as nome, count(rihas.fk_municipio) as tam FROM regiao_interesse ri INNER JOIN regiao_interesse_has_municipio rihas ON ri.id = rihas.fk_regiao_interesse GROUP BY ri.id, ri.nome;"; $q = pg_query($con, $sql) or die("Nao foi possivel executar a consulta!"); $json = array(); if (pg_num_rows($q) > 0) { while ($dados = pg_fetch_object($q)) { $json[] = array('n' => $dados->nome, 'id' => $dados->id, 'tam' => $dados->tam); } } return $json; }
function loadIndicadoresHasTema() { $minhaConexao = new Conexao(); $con = $minhaConexao->open(); $sql = "SELECT fk_variavel,fk_tema FROM variavel_has_tema"; $q = pg_query($con, $sql) or die("Nao foi possivel executar a consulta!"); $json = array(); if (pg_num_rows($q) > 0) { while ($dados = pg_fetch_object($q)) { $json[] = array('variavel' => $dados->fk_variavel, 'tema' => $dados->fk_tema); } } return $json; }
function loadEstados() { $minhaConexao = new Conexao(); $con = $minhaConexao->open(); $sql = "select id,nome from estado order by nome"; //$sql .= " ORDER BY nome "; $q = pg_query($con, $sql) or die("Nao foi possivel executar a consulta!"); $json = array(); if (pg_num_rows($q) > 0) { while ($dados = pg_fetch_object($q)) { $json[] = array('nome' => mb_strtolower($dados->nome, 'UTF-8'), 'id' => $dados->id); } } return $json; }
function loadCidades($value) { $minhaConexao = new Conexao(); $con = $minhaConexao->open(); $sql; //$sql = "select mun.id,mun.nome,mun.fk_estado,est.fk_regiao,est.nome from municipio as mun left join estado as est on mun.fk_estado = est.id"; //select mun.id,mun.fk_estado,mun.nome||'('||est.uf||')' nome from municipio mun left join estado est on mun.fk_estado = est.id if ($value == -1) { $sql = "select mun.id,mun.fk_estado,mun.nome||'('||est.uf||')' nome, fk_regiao from municipio mun left join estado est on mun.fk_estado = est.id"; } else { $sql = "select mun.id,mun.fk_estado,mun.nome||'('||est.uf||')' nome, fk_regiao from municipio mun left join estado est on mun.fk_estado = est.id where fk_estado = {$value}"; } $sql .= " ORDER BY nome "; $q = pg_query($con, $sql) or die("Nao foi possivel executar a consulta!"); $json = array(); if (pg_num_rows($q) > 0) { while ($dados = pg_fetch_object($q)) { $json[] = array('n' => $dados->nome, 'id' => $dados->id, 'e' => $dados->fk_estado, 'r' => $dados->fk_regiao); } } return $json; }
<?php if (empty($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { header("Location: {$path_dir}404"); } include_once "../../../../config/config_path.php"; include_once "../../../../config/config_gerais.php"; include_once "../../../../config/conexao.class.php"; include_once "../../consulta/Consulta.class.php"; $indc = $_POST["indicador"]; $ano = $_POST["ano"]; $spc = $_POST["espacialidade"]; $con = new Conexao(); $response = array(); if ($ano == "all") { $sql = "SELECT cg.id as cg_id,c.id as c_id,c.nome,c.minimo,c.maximo,c.cor_preenchimento FROM classe_grupo cg INNER JOIN classe c " . " ON c.fk_classe_grupo = cg.id WHERE fk_ano_referencia IS NULL AND fk_variavel = {$indc} AND espacialidade = {$spc} ORDER BY c_id DESC;"; } else { $sql = "SELECT cg.id as cg_id,c.id as c_id,c.nome,c.minimo,c.maximo,c.cor_preenchimento FROM classe_grupo cg INNER JOIN classe c " . " ON c.fk_classe_grupo = cg.id WHERE fk_ano_referencia = {$ano} AND fk_variavel = {$indc} AND espacialidade = {$spc} ORDER BY c_id DESC;"; } $r = pg_query($con->open(), $sql) or die("Nao foi possivel executar a consulta!"); while ($obj = pg_fetch_object($r)) { array_push($response, $obj); } echo json_encode($response);
<?php ob_start(); require_once BASE_ROOT . '/config/conexao.class.php'; require_once dirname(__FILE__) . '/../init.php'; require_once dirname(__FILE__) . '/../model/autoload.php'; ini_set('display_errors', DISPLAY_ERRORS); $conexao = new Conexao(); $bd = new Bd($conexao->open()); $rm_dao = new RmDao($bd); $lista_rm = $rm_dao->getContexto(); $json_lista_rm = json_encode($lista_rm->toArray()); $estado_dao = new EstadoDao($bd); $lista_estados = $estado_dao->getContexto(); $json_lista_uf = json_encode($lista_estados->toArray()); /* * Configuração do mapa. */ $mapa_espacialidade = array(ESP_REGIAOMETROPOLITANA => array('sufixo_var' => 'RM', 'nome' => $lang_mng->getString('mp_item_contexto_rm')), ESP_ESTADUAL => array('sufixo_var' => 'UF', 'nome' => $lang_mng->getString('mp_item_contexto_estado')), ESP_PAIS => array('nome' => $lang_mng->getString('mp_item_contexto_brasil'))); ?> <!-- css --> <link rel="stylesheet" type="text/css" href="<?php echo $path_dir; ?> system/modules/map/assets/css/cupertino/jquery-ui-1.10.4.custom.min.css" /> <link rel="stylesheet" type="text/css" href="<?php echo $path_dir; ?> system/modules/map/assets/css/componentes.css" /> <link rel="stylesheet" type="text/css" href="<?php
<?php include_once "/system/modules/tabela/consulta/Consulta.class.php"; include_once "/config/conexao.class.php"; $ocon = new Conexao(); $query = "SELECT id, nomecurto FROM variavel WHERE exibir_na_consulta IS TRUE;"; $res = pg_query($ocon->open(), $query) or die("Nao foi possivel executar a consulta!"); ?> <style type="text/css"> .cls_table { width: 600px; } .ipt_value { width: 100px; height: 100%; } </style> <script type="text/javascript"> var qindex = -1; var qarray;
<?php /* * Serviço indicadores menu. * * @package map * @author AtlasBrasil */ header('Content-Type: application/json'); $dir = dirname(__FILE__); require_once $dir . '/../../../../config/conexao.class.php'; require_once $dir . '/../../../../config/constants.php'; require_once $dir . '/../init.php'; require_once $dir . '/../model/autoload.php'; ini_set('display_errors', DISPLAY_ERRORS); $db_connection = new Conexao(); $db = new Bd($db_connection->open()); $user_lang = isset($_GET['user_lang']) ? $_GET['user_lang'] : 'pt'; $dao = new NomeIndicadorDao($db, $user_lang); echo json_encode($dao->getResultSet()->toArray());
<?php if ($aleatorio == true && $municipio1Arvore == 0 && $municipio2Arvore == 0) { //Conexão ao banco de dados $minhaConexao = new Conexao(); $con = $minhaConexao->open(); //gerando municipios aleatorios $ids = array(rand(1, 5565), rand(1, 5565)); //Pegando nome do município 1 $query1 = "SELECT m.nome, e.uf FROM municipio as m, estado as e WHERE m.id = {$ids[0]} AND m.fk_estado = e.id"; $res = @pg_query($con, $query1) or die("Nao foi possivel executar a consulta!"); while ($linha = pg_fetch_array($res)) { $NomesMun[0] = $linha[0]; $Uf[0] = $linha[1]; } //Pegando nome do município 2 $query2 = "SELECT m.nome, e.uf FROM municipio as m, estado as e WHERE m.id = {$ids[1]} AND m.fk_estado = e.id"; $res = @pg_query($con, $query2) or die("Nao foi possivel executar a consulta!"); while ($linha2 = pg_fetch_array($res)) { $NomesMun[1] = $linha2[0]; $Uf[1] = $linha2[1]; } $NomesMunImp = setNomeImp($NomesMun, $Uf); $NomesMun = retira_acentos($NomesMun); $NomesMunEst = minJunt($NomesMun, $Uf); $Espac = array('municipio', 'municipio'); $Ideal = array('nulo', 'nulo'); $idAnos = array('3', '3'); $Anos = array('2010', '2010'); } if ($municipio1Arvore != '0' || $municipio2Arvore != '0') {
function consults($sql) { $minhaConexao = new Conexao(); $con = $minhaConexao->open(); $result = pg_query($con, $sql) or die("Nao foi possivel executar a consulta!"); $row = pg_fetch_array($result); return $row["valor"]; }
if (empty($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { header("Location: {$path_dir}404"); } include_once "../../../../config/config_path.php"; include_once "../../../../config/config_gerais.php"; include_once "../../../../config/conexao.class.php"; include_once "../../consulta/Consulta.class.php"; $indc = $_POST["indicador"]; $ano = $_POST["ano"]; $spc = $_POST["espacialidade"]; $con = new Conexao(); if ($ano == "all") { $sql = "SELECT id FROM classe_grupo WHERE fk_ano_referencia IS NULL AND fk_variavel = '{$indc}' AND espacialidade='{$spc}' ;"; } else { $sql = "SELECT id FROM classe_grupo WHERE fk_ano_referencia = '{$ano}' AND fk_variavel = '{$indc}' AND espacialidade='{$spc}' ;"; } $r_oldgroupsql = pg_query($con->open(), $sql) or die("Nao foi possivel executar a consulta!"); $oldgroup = pg_fetch_object($r_oldgroupsql); if ($oldgroup) { $remove_cls_sql = "DELETE FROM classe WHERE fk_classe_grupo = '{$oldgroup->id}';"; $r = pg_query($con->open(), $remove_cls_sql) or die("Nao foi possivel executar a consulta!"); $remove_grp_sql = "DELETE FROM classe_grupo WHERE id = {$oldgroup->id}"; $r = pg_query($con->open(), $remove_grp_sql) or die("Nao foi possivel executar a consulta!"); } $r = pg_query($con->open(), $sql) or die("Nao foi possivel executar a consulta!"); while ($obj = pg_fetch_object($r)) { array_push($response, $obj); } $response["msg"] = "Quintil removido com sucesso!"; $response["status"] = "success"; echo json_encode($response);
if (empty($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { header("Location: {$path_dir}404"); } include_once "../../../../config/config_path.php"; include_once "../../../../config/config_gerais.php"; include_once "../../../../config/conexao.class.php"; include_once "../../map/Quantil.php"; include_once "../../consulta/Consulta.class.php"; include_once "../../util/Color.php"; $indc = $_POST["indicador"]; $ano = $_POST["ano"]; $spc = $_POST["espacialidade"]; $response = array(); $quantil = new Quantil(); $con = new Conexao(); $quantil->setLink($con->open()); $decimais_sql = "SELECT decimais FROM variavel WHERE id = {$indc};"; $r_decimais = pg_query($con->open(), $decimais_sql) or die("Nao foi possivel executar a consulta!"); $decimais_obj = pg_fetch_object($r_decimais); if ($decimais_obj != null) { $decimais = $decimais_obj->decimais != null ? (int) $decimais_obj->decimais : 0; } else { $response["msg"] = "Erro ao obter quantidade de casas decimais."; $response["status"] = "no_operation"; echo json_encode($response); die; } if ($ano == "all") { switch ($spc) { case Consulta::$ESP_ESTADUAL: $quartis_info1 = "SELECT COUNT(v.valor) as count ,ROUND(MAX(v.valor),3) as max ,ROUND(MIN(v.valor),3) as min FROM valor_variavel_estado v WHERE v.fk_ano_referencia = 3 and v.fk_variavel = {$indc};";
public function executarSQL($SQL) { $ocon = new Conexao(); $link = $ocon->open(); $resultado = pg_query($link, $SQL) or die("Nao foi possivel executar a consulta! "); $IdMun = array(); while ($Linha = pg_fetch_assoc($resultado)) { $IdMun[] = $Linha; } return $IdMun; }