--- trunk/lib/BackupPC/SearchLib.pm 2005/08/20 16:40:11 51 +++ trunk/lib/BackupPC/SearchLib.pm 2005/08/20 17:19:48 53 @@ -156,41 +156,40 @@ sub getBackupsNotBurned() { my $dbh = DBI->connect($dsn, $db_user, "", { RaiseError => 1, AutoCommit => 1 } ); - my $sql = q{ - SELECT - hosts.ID AS hostID, - hosts.name AS host, - backups.num AS backupno, - backups.type AS type, - backups.date AS date - FROM backups, shares, files, hosts - WHERE - backups.num = files.backupNum AND - shares.ID = files.shareID AND - backups.hostID = shares.hostID AND - hosts.ID = backups.hostID AND - files.dvdid IS NULL - GROUP BY - backups.hostID, backups.num - }; - my $st = $dbh -> prepare( $sql ); - my @ret = (); - $st -> execute(); + my $sql = q{ + SELECT + hosts.ID AS hostid, + min(hosts.name) AS host, + backups.num AS backupno, + min(backups.type) AS type, + min(backups.date) AS date + FROM backups, shares, files, hosts + WHERE + backups.num = files.backupNum AND + shares.ID = files.shareID AND + backups.hostID = shares.hostID AND + hosts.ID = backups.hostID AND + files.dvdid IS NULL + GROUP BY + backups.hostID, backups.num, hosts.id + }; + my $sth = $dbh->prepare( $sql ); + my @ret; + $sth->execute(); - while ( my $row = $st -> fetchrow_hashref() ) - { - push(@ret, { + while ( my $row = $sth->fetchrow_hashref() ) { + push(@ret, { 'host' => $row->{'host'}, - 'hostid' => $row->{'hostID'}, + 'hostid' => $row->{'hostid'}, 'backupno' => $row->{'backupno'}, 'type' => $row->{'type'}, 'date' => $row->{'date'} } - ); + ); } - return @ret; - } + return @ret; +} sub displayBackupsGrid() {