EDITed and explain in full details
I working with a project with this scenario.
Each user has a "UID" which is unique ID.
They can add their own "item_option_name" and "item_option_value".
"item_option_name" is not allowed to be duplicated but "item_option_value" is allowed.
database_table
update_mysql
public function update_option($uid,$oid,$item_option_name,$option_value){
$sql_check="SELECT * FROM options where uid='$uid' and item_option_name='$item_option_name'";
if($this->conn->row_count($sql_check)==true){
return false;
}else{
$sql = "UPDATE options SET item_option_name='$item_option_name', item_option_value='$option_value' WHERE oid='$oid'";
$this->conn->update($sql);
return true;
}
}
When i submit the form, Update function will work if i change item_option_name to something else. It won't work if item_option_name remain unchanged.
Example 1. If i want to update Size
item_option_name=Size_new
item_option_value ="large,extra large"
and then submit form. It works fine
Example 2.
item_option_name=Size
item_option_value ="large,extra large"
and then submit form. item_option_name remains same. It won't work due to "Size" already exist.
Anyone know how to fix this issue?