Example #1
0
 function DoList()
 {
     $qid = intval($this->Get['qid']);
     if (!$qid) {
         widget_error('Id is empty', 102);
     }
     $page = intval($this->Get['page']);
     $page_size = intval($this->Get['page_size']);
     $page_size = $page_size == 0 ? 10 : $page_size;
     if (!$this->QunLogic->is_exists($qid)) {
         widget_error('Id is invalid', 103);
     }
     $where_sql = " tq.item_id='{$qid}' ";
     $order_sql = " t.dateline DESC ";
     $total_record = DB::result_first("SELECT COUNT(*)\r\n\t\t\t\t\t\t\t\t   \t\t  FROM " . DB::table('topic') . " AS t\r\n\t\t\t\t\t\t\t\t   \t\t  LEFT JOIN " . DB::table('topic_qun') . " AS tq\r\n\t\t\t\t\t\t\t\t   \t\t  USING(tid)\r\n\t\t\t\t\t\t\t\t   \t\t  WHERE {$where_sql}");
     if ($total_record > 0) {
         $page_arr = $this->_page($total_record, $page_size);
         $query = DB::query("SELECT t.*\r\n\t\t\t\t\t\t\t\tFROM " . DB::table('topic') . " AS t\r\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB::table('topic_qun') . " AS tq\r\n\t\t\t\t\t\t\t\tUSING(tid)\r\n\t\t\t\t\t\t\t\tWHERE {$where_sql}\r\n\t\t\t\t\t\t\t\tORDER BY {$order_sql}\r\n\t\t\t\t\t\t\t\tLIMIT {$page_arr['offset']},{$page_arr['limit']}");
         $topic_list = array();
         while ($value = DB::fetch($query)) {
             $topic_list[] = $value;
         }
         $topic_list = $this->TopicLogic->MakeAll($topic_list);
         $data = array('total_record' => $total_record, 'topic_list' => $topic_list, 'page_arr' => $page_arr);
         widget_output($data);
     } else {
         widget_error('List is empty', 104);
     }
 }
Example #2
0
function widget_error($msg, $code = 0, $halt = true)
{
    widget_output($msg, 'error', $code);
    $halt && exit;
}