示例#1
0
 function FindByPagination($perpage, $pagenum)
 {
     // Check to see if there is a page number. If not, set it to page 1
     if (!isset($pagenum)) {
         $pagenum = 1;
     }
     $last = Galleries::FindLastPage($perpage);
     // Ensure the page number isn't below one, or more than the maximum pages
     if ($pagenum < 1) {
         $pagenum = 1;
     } elseif ($pagenum > $last) {
         $pagenum = $last;
     }
     // Sets the limit value for the query
     $max = 'LIMIT ' . ($pagenum - 1) * $perpage . ', ' . $perpage;
     return MyActiveRecord::FindBySQL('Galleries', "SELECT * FROM galleries ORDER BY id DESC {$max}");
 }