Пример #1
0
 function get_index_list($count, $type)
 {
     switch ($type) {
         case 'popular':
             $query = he_database::placeholder("SELECT `quiz`.*, COUNT(`play`.`id`) AS `takes` FROM `se_he_quiz` AS `quiz`\r\n\t\t\t\t\tLEFT JOIN `se_he_quiz_play` AS `play` ON(`quiz`.`quiz_id`=`play`.`quiz_id`)\r\n\t\t\t\t\tWHERE `quiz`.`status`=1 AND `quiz`.`approved`=1\r\n\t\t\t\t\tGROUP BY `quiz`.`quiz_id`\r\n\t\t\t\t\tORDER BY `takes` DESC LIMIT ?, ?", 0, $count);
             break;
         case 'commented':
             $query = he_database::placeholder("SELECT `quiz`.*, COUNT(`comment`.`he_quizcomment_id`) AS `comment`\r\n                    FROM `se_he_quiz` AS `quiz`\r\n                    LEFT JOIN `se_he_quizcomments` AS `comment` ON(`quiz`.`quiz_id`=`comment`.`he_quizcomment_quiz_id`)\r\n                    WHERE `quiz`.`status`=1 AND `quiz`.`approved`=1\r\n                    GROUP BY `quiz`.`quiz_id`\r\n                    ORDER BY `comment` DESC LIMIT ?, ?", 0, $count);
             break;
         default:
             $query = he_database::placeholder("SELECT * FROM `se_he_quiz` \r\n                    WHERE `status`=1 AND `approved`=1\r\n                    ORDER BY `id` DESC LIMIT ?, ?", 0, $count);
             break;
     }
     $res = he_database::query($query);
     $quiz_list = array();
     while ($quiz = he_database::fetch_row_from_resource($res)) {
         $quiz['photo_url'] = $quiz['photo'] ? he_quiz::photo_url() . $quiz['photo'] : '';
         $quiz['photo_dir'] = $quiz['photo'] ? he_quiz::photo_dir() . $quiz['photo'] : '';
         $quiz['size'] = getimagesize($quiz['photo_dir']);
         $quiz_list[$quiz['quiz_id']] = $quiz;
     }
     return $quiz_list;
 }