Ignore:
Timestamp:
07/07/08 17:53:43 (4 years ago)
Author:
hverton
Message:

test if the report query is correct and whould produce any results before showing it

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/common/download_statistics/php-files/modules/download_statistics/report.topfiles.php

    r1499 r1528  
    8080 
    8181            // check how many rows this would output 
    82             $rptresult = dbquery($sql.($top ? (" LIMIT 0,".$top) : "")); 
    83             // store some row counter for the pager 
    84             $variables['rows'] = dbrows($rptresult); 
    85             $variables['rowstart'] = $rowstart; 
     82            $rptresult = mysql_query($sql); 
     83            if ($rptresult) { 
     84                // store some row counter for the pager 
     85                $variables['rows'] = dbrows($rptresult); 
     86                $variables['rowstart'] = $rowstart; 
    8687 
    87             // now add a query limit, make sure not to overshoot the limit requested 
    88             if ($top > 0 && $rowstart+$settings['numofthreads'] > $top) { 
    89                 $rowstart = max(0, $limit - $settings['numofthreads']); 
     88                // now add a query limit, make sure not to overshoot the limit requested 
     89                if ($top > 0 && $rowstart+$settings['numofthreads'] > $top) { 
     90                    $rowstart = max(0, $limit - $settings['numofthreads']); 
     91                } else { 
     92                    // technically, this is never going to be the limit ;-) 
     93                    $top = 99999999999999; 
     94                } 
     95                $rptresult = dbquery($sql." LIMIT ".$rowstart.",".min($rowstart+$top, $settings['numofthreads'])); 
     96 
     97                // get the results 
     98                $reportvars['output'] = array(); 
     99                while ($rptdata = dbarray($rptresult)) { 
     100                    $reportvars['output'][] = $rptdata; 
     101                } 
    90102            } else { 
    91                 // technically, this is never going to be the limit ;-) 
    92                 $top = 99999999999999; 
     103                $variables['message'] = $locale['dls950']." ".mysql_error(); 
    93104            } 
    94             $rptresult = dbquery($sql." LIMIT ".$rowstart.",".min($rowstart+$top, $settings['numofthreads'])); 
    95  
    96             // get the results 
    97             $reportvars['output'] = array(); 
    98             while ($rptdata = dbarray($rptresult)) { 
    99                 $reportvars['output'][] = $rptdata; 
    100             } 
    101  
    102105        } 
    103106    } 
Note: See TracChangeset for help on using the changeset viewer.