PenParametroBD.php
1.74 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
<?php
require_once dirname(__FILE__) . '/../../../SEI.php';
/**
* Classe gererica de persistncia com o banco de dados
*
* @author Join Tecnologia
*/
class PenParametroBD extends InfraBD {
public function setValor($strNome, $strValor) {
$sql = '';
$sql .= ' SELECT count(*) as existe';
$sql .= ' FROM md_pen_parametro ';
$sql .= ' WHERE nome=' . $this->getObjInfraIBanco()->formatarGravacaoStr($strNome);
$rs = $this->getObjInfraIBanco()->consultarSql($sql);
if ($rs[0]['existe'] == 0) {
if (strlen($strNome) > 100) {
throw new InfraException('Nome do parâmetro possui tamanho superior a 100 caracteres.');
}
$sql = '';
$sql .= ' INSERT INTO infra_parametro (nome,valor)';
$sql .= ' VALUES ';
$sql .= ' (' . $this->getObjInfraIBanco()->formatarGravacaoStr($strNome) . ',' . $this->getObjInfraIBanco()->formatarGravacaoStr($strValor) . ')';
} else {
$sql = '';
$sql .= ' UPDATE infra_parametro ';
$sql .= ' SET valor = ' . $this->getObjInfraIBanco()->formatarGravacaoStr($strValor);
$sql .= ' WHERE nome = ' . $this->getObjInfraIBanco()->formatarGravacaoStr($strNome);
}
$ret = $this->getObjInfraIBanco()->executarSql($sql);
return $ret;
}
public function isSetValor($strNome) {
$sql = '';
$sql .= ' SELECT valor';
$sql .= ' FROM md_pen_parametro ';
$sql .= ' WHERE nome = ' . $this->getObjInfraIBanco()->formatarGravacaoStr($strNome);
$rs = $this->getObjInfraIBanco()->consultarSql($sql);
if (count($rs) == 0) {
return false;
}
return true;
}
}