HT = $this->load->database('HT', TRUE); $this->INFO = $this->load->database('INFO', TRUE); } public function init() { $this->topnum = false; $this->where = false; $this->orderby = ' ORDER BY psd_Datetime ASC '; } public function detail($psd_URL, $psd_SiteCode) { $this->init(); $this->topnum = 1; $this->where = ' AND psd.psd_URL=' . $this->INFO->escape($psd_URL); $this->where = ' AND psd.psd_SiteCode=' . $this->INFO->escape($psd_SiteCode); return $this->get_list(); } public function add($table, $data) { if ($this->INFO->insert($table, $data)) { return $this->INFO->last_id($table); } else { return false; } } public function update($table, $data, $where) { $this->INFO->update($table, $data, $where); } public function get_list() { $this->topnum ? $sql = "SELECT TOP " . $this->topnum : $sql = "SELECT "; $sql .= " psd.psd_id, psd.psd_DesktopScore, psd.psd_MobileScore, psd.psd_DesktopData, psd.psd_MobileData, psd.psd_URL, psd.psd_Datetime, psd.psd_SiteCode, psd.psd_ErrorCount FROM PageSpeedData psd WHERE 1 = 1 "; $this->where ? $sql.=$this->where : false; $this->orderby ? $sql.=$this->orderby : false; $query = $this->INFO->query($sql); //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(); } } }