diff --git a/application/controllers/User_options.php b/application/controllers/User_options.php index c021dfb0..c5360590 100755 --- a/application/controllers/User_options.php +++ b/application/controllers/User_options.php @@ -11,7 +11,12 @@ class User_Options extends CI_Controller { public function add_edit_fav() { $obj = json_decode(file_get_contents("php://input"), true); - $this->user_options_model->set_option('Favourite',$obj); + if ($obj['sat_name'] ?? '' != '') { + $option_name=$obj['sat_name']; + } else { + $option_name=$obj['band'].'/'.$obj['mode']; + } + $this->user_options_model->set_option('Favourite',$option_name, $obj); } } diff --git a/application/models/User_options_model.php b/application/models/User_options_model.php index 68e07816..1304abd0 100644 --- a/application/models/User_options_model.php +++ b/application/models/User_options_model.php @@ -8,11 +8,11 @@ class User_options_model extends CI_Model return $this->db->get('user_options'); } - public function set_option($option_type, $option_array) { + public function set_option($option_type, $option_name, $option_array) { $uid=$this->session->userdata('user_id'); - $sql='insert into user_options (user_id,option_type,option_key,option_value) values (?,?,?,?) ON DUPLICATE KEY UPDATE option_value=?'; + $sql='insert into user_options (user_id,option_type,option_name,option_key,option_value) values (?,?,?,?,?) ON DUPLICATE KEY UPDATE option_value=?'; foreach($option_array as $option_key => $option_value) { - $query = $this->db->query($sql, array($uid, $option_type, $option_key, $option_value, $option_value)); + $query = $this->db->query($sql, array($uid, $option_type, $option_name, $option_key, $option_value, $option_value)); } }