*model* class M_belajar extends CI_Model { function save($datasensor) { $this->db->insert('tbl_water_level', $datasensor); return TRUE; } function river() { $query = $this->db->select('river_id')->from('tbl_activation')->order_by('activation_id', 'DESC')->limit('1')->get(); return $query->row()->river_id; } *controller* public function sensor(){ $this->load->model('m_belajar'); if (isset($_GET['data'])) { $panjang = $this->input->get('data'); $river_id['river'] = $this->m_belajar->river(); print_r($river_id); $datasensor = array('water_distance' => $panjang, 'water_time' => time(), 'river_id' => $river_id );