Added option_name to table

This commit is contained in:
int2001 2023-08-18 13:30:04 +00:00
parent 1bf2840e27
commit 59f81279e3
No known key found for this signature in database
GPG Key ID: DFB1C13CD2DB037B
2 changed files with 9 additions and 4 deletions

View File

@ -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);
}
}

View File

@ -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));
}
}