HT = $this->load->database('HT', TRUE); } function init() { $this->top_num=false; $this->pt_id=false; $this->order_by=" ORDER BY ipt.pt_id DESC "; } function task_list($p_id) { $this->init(); $this->pt_id=" AND ipt.pt_p_id=".$this->HT->escape($p_id); return $this->get_list(); } function get_list() { $this->top_num ? $sql = "SELECT TOP " . $this->top_num : $sql = "SELECT "; $sql .= " ipt.pt_id \n" ." ,ipt.pt_p_id \n" ." ,ipt.pt_title \n" ." ,ipt.pt_poster \n" ." ,ipt.pt_accepter \n" ." ,ipt.pt_content \n" ." ,ipt.pt_datetime \n" ." FROM infoprojecttasks ipt \n" . "WHERE 1 = 1 \n "; $this->pt_id ? $sql.=$this->pt_id : false; $this->order_by ? $sql.=$this->order_by : false; $query=$this->HT->query($sql); if($this->top_num==1) { if ($query->num_rows() > 0) { $row = $query->row(); return $row; } else { return FALSE; } } else { return $query->result(); } } }