funcoes.php
2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace admin\metaestat\fontes;
use PDOException;
function listar($dbh, $id_fonteinfo = "") {
$esquemaadmin = $_SESSION ["esquemaadmin"];
if ($id_fonteinfo != "") {
$dados = \admin\php\funcoesAdmin\pegaDados ( "SELECT * from " . $esquemaadmin . "i3geoestat_fonteinfo WHERE id_fonteinfo = $id_fonteinfo ", $dbh, false );
$dados = $dados [0];
} else {
$dados = \admin\php\funcoesAdmin\pegaDados ( "SELECT * from " . $esquemaadmin . "i3geoestat_fonteinfo order by lower(titulo)", $dbh, false );
}
if ($dados === false) {
return false;
} else {
return $dados;
}
}
function adicionar($titulo, $link, $dbhw) {
$esquemaadmin = $_SESSION ["esquemaadmin"];
try {
$dataCol = array (
"titulo" => '',
"link" => ''
);
$id_fonteinfo = \admin\php\funcoesAdmin\i3GeoAdminInsertUnico ( $dbhw, "i3geoestat_fonteinfo", $dataCol, "titulo", "id_fonteinfo" );
$retorna = \admin\metaestat\fontes\alterar ( $id_fonteinfo, $titulo, $link, $dbhw );
return $retorna;
} catch ( PDOException $e ) {
return false;
}
}
function alterar($id_fonteinfo, $titulo, $link, $dbhw) {
$esquemaadmin = $_SESSION ["esquemaadmin"];
$convUTF = $_SESSION["convUTF"];
if ($convUTF != true){
$titulo = utf8_decode($titulo);
}
$dataCol = array (
"titulo" => $titulo,
"link" => $link
);
$resultado = \admin\php\funcoesAdmin\i3GeoAdminUpdate ( $dbhw, "i3geoestat_fonteinfo", $dataCol, "WHERE id_fonteinfo = $id_fonteinfo" );
if ($resultado === false) {
return false;
}
return $id_fonteinfo;
}
function excluir($id_fonteinfo, $dbhw) {
$esquemaadmin = $_SESSION ["esquemaadmin"];
$r = \admin\php\funcoesAdmin\pegaDados("select * from ".$esquemaadmin."i3geoestat_fonteinfo_medida where id_fonteinfo=$id_fonteinfo");
if(count($r) > 0){
header ( "HTTP/1.1 500 erro ao excluir. Essa fonte esta em uso por i3geoestat_fonteinfo_medida" );
exit ();
}
$resultado = \admin\php\funcoesAdmin\i3GeoAdminExclui ( $esquemaadmin . "i3geoestat_fonteinfo", "id_fonteinfo", $id_fonteinfo, $dbhw, false );
if ($resultado === false) {
return false;
}
return $resultado;
}
?>