push( @conditions, ' files.shareid = ' . $param->{'search_share'} ) if ($param->{'search_share'});
push (@conditions, " upper(files.path) LIKE upper('%".$param->{'search_filename'}."%')") if ($param->{'search_filename'});
- if ( $param->{burned} ) {
- my $is_what = 'is null';
- $is_what = '= 1' if ($param->{burned} eq 'burned');
- push @conditions, "archive_burned.part $is_what";
- push @conditions, "archive_burned.copy $is_what";
- }
+ push @conditions, join(' ' , 'burned is', $param->{burned} eq 'burned' ? '' : 'not', 'true') if $param->{burned};
return join(" and ", @conditions);
}
# do we have to add tables for burned media?
if ( $param->{burned} ) {
$sql_from .= qq{
- LEFT OUTER JOIN archive_backup_parts on backup_id = backups.id
- LEFT OUTER JOIN archive_burned on archive_burned.archive_id = archive_id
+ LEFT OUTER JOIN backups_burned on backup_id = backups.id
};
}
OFFSET ?
};
- my $sql_count = qq{ select count(files.id) $sql_from $sql_where };
my $sql_results = qq{ select $sql_cols $sql_from $sql_where $sql_order };
-
- my $sth = $dbh->prepare($sql_count);
- $sth->execute();
- my ($results) = $sth->fetchrow_array();
-
- $sth = $dbh->prepare($sql_results);
+ my $sth = $dbh->prepare($sql_results);
$sth->execute( $offset );
- if ($sth->rows != $results) {
- my $bug = "$0 BUG: [[ $sql_count ]] = $results while [[ $sql_results ]] = " . $sth->rows;
- $bug =~ s/\s+/ /gs;
- print STDERR "$bug\n";
- }
-
my @ret;
while (my $row = $sth->fetchrow_hashref()) {
}
$sth->finish();
- return ($results, \@ret);
+ return ($sth->rows, \@ret);
}
sub getFilesHyperEstraier($) {