From: Davide Franco Date: Tue, 5 Jul 2011 21:21:32 +0000 (+0200) Subject: bacula-web: Fixed bug with pgsql queries X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=850b59027b281aabdeb94b1f59b61604d8ce213f;p=bacula%2Fbacula bacula-web: Fixed bug with pgsql queries --- diff --git a/gui/bacula-web/includes/bweb.inc.php b/gui/bacula-web/includes/bweb.inc.php index 10bea91363..afb36a6525 100644 --- a/gui/bacula-web/includes/bweb.inc.php +++ b/gui/bacula-web/includes/bweb.inc.php @@ -557,10 +557,25 @@ class Bweb extends DB public function GetStoredBytesByJob( $jobname, $start_date, $end_date ) { - $query = "SELECT SUM(JobBytes) as stored_bytes, EndTime FROM Job "; - $query .= "WHERE ( EndTime BETWEEN '$start_date' AND '$end_date' ) AND "; - $query .= "Name = '$jobname'"; + $query = ''; + switch( $this->driver ) + { + case 'sqlite': + case 'mysql': + $query = "SELECT SUM(JobBytes),EndTime as stored_bytes FROM Job "; + $query .= "WHERE ( EndTime BETWEEN '$start_date' AND '$end_date' ) AND "; + $query .= "Name = '$jobname'"; + $query .= "GROUP BY EndTime"; + break; + case 'pgsql': + $query = "SELECT SUM(jobbytes),endtime as stored_bytes FROM job "; + $query .= "WHERE ( endtime BETWEEN timestamp '$start_date' AND timestamp '$end_date' ) AND "; + $query .= "name = '$jobname'"; + $query .= "GROUP BY EndTime"; + break; + } + $result = $this->db_link->query( $query ); if( PEAR::isError( $result ) ) { @@ -583,9 +598,24 @@ class Bweb extends DB public function GetStoredFilesByJob( $jobname, $start_date, $end_date ) { - $query = "SELECT SUM(JobFiles) as stored_files, EndTime FROM Job "; - $query .= "WHERE ( EndTime BETWEEN '$start_date' AND '$end_date' ) AND "; - $query .= "Name = '$jobname'"; + $query = ''; + + switch( $this->driver ) + { + case 'sqlite': + case 'mysql': + $query = "SELECT SUM(JobFiles),EndTime as stored_bytes FROM Job "; + $query .= "WHERE ( EndTime BETWEEN '$start_date' AND '$end_date' ) AND "; + $query .= "Name = '$jobname'"; + $query .= "GROUP BY EndTime"; + break; + case 'pgsql': + $query = "SELECT SUM(jobfiles),endtime as stored_bytes FROM job "; + $query .= "WHERE ( endtime BETWEEN timestamp '$start_date' AND timestamp '$end_date' ) AND "; + $query .= "name = '$jobname'"; + $query .= "GROUP BY EndTime"; + break; + } $result = $this->db_link->query( $query );