]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Fixed bug with pgsql queries
authorDavide Franco <bacula-dev@dflc.ch>
Tue, 5 Jul 2011 21:21:32 +0000 (23:21 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:19 +0000 (14:49 +0200)
gui/bacula-web/includes/bweb.inc.php

index 10bea913636915b1b97a78834c3a228776ecd637..afb36a65256bece3f6d3d23cec8826da48431444 100644 (file)
@@ -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 );