code: protected function getTopDownloads($limit=20)
      {
          $arrTopDownloads = array();
          $objTopDownloads = \Database::getInstance()->prepare("SELECT `tstamp`, `filename`, `downloads`, `id`
                                                                FROM `tl_dlstats`
                                                                ORDER BY `downloads` DESC")
                                                     ->limit($limit)
                                                     ->execute();
          $intRows = $objTopDownloads->numRows;
          if ($intRows>0)
          {
              while ($objTopDownloads->next())
              {
                  $c4d = $this->check4details($objTopDownloads->id);
                  $arrTopDownloads[] = array( $objTopDownloads->filename
                                            , $this->getFormattedNumber($objTopDownloads->downloads,0)
                                            , $this->parseDate($GLOBALS['TL_CONFIG']['datimFormat'], $objTopDownloads->tstamp)
                                            , $objTopDownloads->id
                                            , $c4d
                                            , $objTopDownloads->downloads //no formatted number for sorting
                                            , $objTopDownloads->tstamp //for sorting
                                            );
              }
          }
  
          return $arrTopDownloads;
      }
docs: Get TOP Downloadlist
  @param number $limit    optional
  @return array    $arrTopDownloads