Commit 8128f43452304e63e0378fa75c6bf885a536d1c7
1 parent
afebfa3b
Exists in
master
and in
1 other branch
Correcoes para SQLServer
Showing
1 changed file
with
18 additions
and
12 deletions
Show diff stats
rn/MdEstatisticasColetarRN.php
... | ... | @@ -492,26 +492,32 @@ class MdEstatisticasColetarRN extends InfraRN |
492 | 492 | } |
493 | 493 | $current_month = date("Y-m-01"); |
494 | 494 | $sgbd = $this->obterTipoSGBD(); |
495 | - if ($sgbd == 'Oracle') { | |
496 | - $query = "SELECT to_char(dth_acesso, 'YYYY') AS ano, to_char(dth_acesso, 'MM') AS mes, recurso, count(*) as quantidade FROM sei.infra_auditoria WHERE dth_acesso > date '%s' AND dth_acesso < date '%s' GROUP BY to_char(dth_acesso, 'YYYY'), to_char(dth_acesso, 'MM'), recurso"; | |
497 | - } else { | |
495 | + if ($sgbd == 'MySql') { | |
498 | 496 | $query = "SELECT year(dth_acesso) as ano, month(dth_acesso) as mes, recurso, count(*) as quantidade FROM sei.infra_auditoria where date(dth_acesso) > '%s' and date(dth_acesso) < '%s' group by 1, 2, 3 order by 1, 2, 3"; |
497 | + } elseif ($sgbd == 'SqlServer') { | |
498 | + $query = "SELECT year(dth_acesso) as ano, month(dth_acesso) as mes, recurso, count(*) as quantidade FROM infra_auditoria where dth_acesso > '%s' and dth_acesso < '%s' group by year(dth_acesso), month(dth_acesso), recurso order by 1, 2, 3"; | |
499 | + } elseif ($sgbd == 'Oracle'){ | |
500 | + $query = "SELECT to_char(dth_acesso, 'YYYY') AS ano, to_char(dth_acesso, 'MM') AS mes, recurso, count(*) as quantidade FROM sei.infra_auditoria WHERE dth_acesso > date '%s' AND dth_acesso < date '%s' GROUP BY to_char(dth_acesso, 'YYYY'), to_char(dth_acesso, 'MM'), recurso"; | |
501 | + } | |
502 | + if ($query) { | |
503 | + $query = sprintf($query, $dataultimorecurso, $current_month); | |
504 | + InfraDebug::getInstance()->gravar('Query: ' . $query, InfraLog::$INFORMACAO); | |
505 | + return BancoSEI::getInstance()->consultarSql($query); | |
499 | 506 | } |
500 | - $query = sprintf($query, $dataultimorecurso, $current_month); | |
501 | - | |
502 | - InfraDebug::getInstance()->gravar('Query: ' . $query, InfraLog::$INFORMACAO); | |
503 | - | |
504 | - return BancoSEI::getInstance()->consultarSql($query); | |
505 | 507 | } |
506 | 508 | |
507 | 509 | public function obterQuantidadeLogErro() { |
508 | 510 | $sgbd = $this->obterTipoSGBD(); |
509 | - if ($sgbd == 'Oracle') { | |
510 | - $query = "select to_char(dth_log, 'YYYY') AS ano, to_char(dth_log, 'MM') AS mes, to_char(dth_log, 'WW') AS semana, count(*) as quantidade from sei.infra_log where sta_tipo = 'E' GROUP BY to_char(dth_log, 'YYYY'), to_char(dth_log, 'MM'), to_char(dth_log, 'WW')"; | |
511 | - } else { | |
511 | + if ($sgbd == 'MySql') { | |
512 | 512 | $query = "select year(dth_log) ano, month(dth_log) mes, week(dth_log) + 1 semana, count(*) as quantidade from sei.infra_log where sta_tipo = 'E' group by 1, 2, 3"; |
513 | + } elseif ($sgbd == 'SqlServer') { | |
514 | + $query = "select year(dth_log) ano, month(dth_log) mes, datepart(week, dth_log) semana, count(*) as quantidade from infra_log where sta_tipo = 'E' group by year(dth_log), month(dth_log), datepart(week, dth_log)"; | |
515 | + } elseif ($sgbd == 'Oracle'){ | |
516 | + $query = "select to_char(dth_log, 'YYYY') AS ano, to_char(dth_log, 'MM') AS mes, to_char(dth_log, 'WW') AS semana, count(*) as quantidade from sei.infra_log where sta_tipo = 'E' GROUP BY to_char(dth_log, 'YYYY'), to_char(dth_log, 'MM'), to_char(dth_log, 'WW')"; | |
517 | + } | |
518 | + if ($query) { | |
519 | + return BancoSEI::getInstance()->consultarSql($query); | |
513 | 520 | } |
514 | - return BancoSEI::getInstance()->consultarSql($query); | |
515 | 521 | } |
516 | 522 | } |
517 | 523 | ?> | ... | ... |