From: Davide Franco Date: Sun, 26 Jun 2011 17:24:30 +0000 (+0200) Subject: bacula-web: Fixed bug in GetStoredBytesByInterval() function X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f45f01acc22eb729b082a92a2ca4c32ca7d8c596;p=bacula%2Fbacula bacula-web: Fixed bug in GetStoredBytesByInterval() function - Fixed carriage return in TriggerDBError() function --- diff --git a/gui/bacula-web/includes/bweb.inc.php b/gui/bacula-web/includes/bweb.inc.php index 04e1a6221e..efdbbf1fc8 100644 --- a/gui/bacula-web/includes/bweb.inc.php +++ b/gui/bacula-web/includes/bweb.inc.php @@ -486,12 +486,22 @@ class Bweb extends DB public function GetStoredBytesByInterval( $start_date, $end_date ) { - $query = "SELECT SUM(JobBytes) as stored_bytes, EndTime FROM Job WHERE EndTime BETWEEN '$start_date' AND '$end_date'"; + $query = ''; + + switch($this->driver) { + case 'sqlite': + case 'mysql': + $query = "SELECT SUM(JobBytes) as stored_bytes FROM Job WHERE (EndTime BETWEEN '$start_date' AND '$end_date')"; + break; + case 'pgsql': + $query = "SELECT SUM(JobBytes) as stored_bytes FROM Job WHERE (EndTime BETWEEN '$start_date' AND '$end_date')"; + break; + } $result = $this->db_link->query( $query ); if( PEAR::isError( $result ) ) { - die( "Unable to get Job Bytes from catalog" ); + $this->TriggerDBError( "Unable to get Job Bytes from catalog", $result ); }else{ $stored_bytes = 0; $tmp = $result->fetchRow( DB_FETCHMODE_ASSOC ); @@ -558,10 +568,10 @@ class Bweb extends DB private function TriggerDBError( $message, $db_error) { echo 'Error: ' . $message . '
'; - echo 'Standard Message: ' . $db_error->getMessage() . "\n"; - echo 'Standard Code: ' . $db_error->getCode() . "\n"; - echo 'DBMS/User Message: ' . $db_error->getUserInfo() . "\n"; - echo 'DBMS/Debug Message: ' . $db_error->getDebugInfo() . "\n"; + echo 'Standard Message: ' . $db_error->getMessage() . '
'; + echo 'Standard Code: ' . $db_error->getCode() . '
'; + echo 'DBMS/User Message: ' . $db_error->getUserInfo() . '
'; + echo 'DBMS/Debug Message: ' . $db_error->getDebugInfo() . '
'; exit; } } // end class Bweb diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index e665c449c0..a89bed4e74 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -134,7 +134,7 @@ $result = $dbSql->db_link->query( $query ); if ( PEAR::isError( $result ) ) die( "Unable to get last used volumes from catalog \n " . $result->getMessage() ); else { - while ( $vol = $result->fetchRow( DB_FETCHMODE_ASSOC ) ) + while ( $vol = $result->fetchRow() ) array_push( $vol_list, $vol ); } $dbSql->tpl->assign( 'volume_list', $vol_list );