Esempio n. 1
0
 function list_by_qid($qid, $ordertype = 1, $rownum = 0, $start = 0, $limit = 10)
 {
     $answerlist = array();
     $already = 0;
     if (1 == $ordertype) {
         $timeorder = 'ASC';
         $floor = $start + 1;
     } else {
         $timeorder = 'DESC';
         $floor = $start ? $rownum - $start : $rownum;
     }
     $query = $this->db->query("SELECT * FROM " . DB_TABLEPRE . "answer WHERE qid={$qid} AND status>0 AND adopttime =0  ORDER BY supports DESC,time {$timeorder} LIMIT {$start},{$limit}");
     while ($answer = $this->db->fetch_array($query)) {
         if ($answer['authorid'] == $this->base->user['uid']) {
             $already = 1;
         }
         $answer['floor'] = $floor;
         $answer['time'] = tdate($answer['time']);
         $answer['ip'] = formatip($answer['ip']);
         $answer['author_avartar'] = get_avatar_dir($answer['authorid']);
         $answer['appends'] = $this->get_appends($answer['id']);
         $answerlist[] = $answer;
         if (1 == $floor) {
             $floor++;
         } else {
             $floor--;
         }
     }
     return array($answerlist, $already);
 }
Esempio n. 2
0
 function get($id)
 {
     $question = $this->db->fetch_first("SELECT * FROM " . DB_TABLEPRE . "question WHERE id='{$id}'");
     if ($question) {
         $question['format_time'] = tdate($question['time']);
         $question['ip'] = formatip($question['ip']);
         $question['author_avartar'] = get_avatar_dir($question['authorid']);
     }
     return $question;
 }