HT = $this->load->database('HT', TRUE); } public function init() { $this->topnum = false; $this->where = false; $this->orderby = ' order by ir_datetime desc '; } public function detail($ir_is_id,$ir_name){ $this->init(); $this->topnum = 1; $this->where = ' AND ir.ir_is_id=' . $this->HT->escape($ir_is_id); $this->where .= ' AND ir.ir_name=' . $this->HT->escape($ir_name); return $this->get_list(); } public function detail_by_ir_id($ir_id){ $this->init(); $this->topnum = 1; $this->where = ' AND ir.ir_id=' . $this->HT->escape($ir_id); return $this->get_list(); } public function get_list() { $this->topnum ? $sql = "SELECT TOP " . $this->topnum : $sql = "SELECT "; $sql .= " ir.ir_id ,ir.ir_is_id ,ir.ir_keyword ,ir.ir_name ,ir.ir_pointer_is_id ,ir.ir_pointer_it_id ,ir.ir_rule ,ir.ir_urls ,ir.ir_datetime ,ir.ir_sitecode from infoRecommends ir where 1=1 AND ir.ir_sitecode=? "; $this->where ? $sql.=$this->where : false; $this->orderby ? $sql.=$this->orderby : false; $query = $this->HT->query($sql,array($this->config->item('site_code'))); //print_r($this->INFO->queries); if ($this->topnum === 1) { if ($query->num_rows() > 0) { $row = $query->row(); return $row; } else { return FALSE; } } else { return $query->result(); } } public function add($table, $data) { if ($this->HT->insert($table, $data)) { return $this->HT->last_id($table); } else { return false; } } public function update($table, $data, $where) { return $this->HT->update($table, $data, $where); } public function delete($table, $where) { return $this->HT->delete($table, $where); } }