public function save_global_rule($global_rule, $company_type_id) { $table = 'shipping_global_function'; $where = array('company_type_id' => $company_type_id); $data = array('global_rule' => $global_rule); if (parent::check_exists($table, $where)) { $this->update($table, $where, $data); } else { $data['company_type_id'] = $company_type_id; $this->db->insert($table, $data); } }