HT = $this->load->database('HT', TRUE); } public function init() { $this->topnum = false; $this->where = false; $this->orderby = ' order by it_expires ASC '; } public function detail($it_id){ $this->init(); $this->topnum = 1; $this->where = ' AND it.it_id=' . $this->HT->escape($it_id); return $this->get_list(); } public function get_list() { $this->topnum ? $sql = "SELECT TOP " . $this->topnum : $sql = "SELECT "; $sql .= " it.it_id ,it.it_title ,it.it_expires ,it.it_content ,it.it_sitecode ,it.it_datetime from infoTips it where 1=1 AND it.it_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); } }