I have a requirement to update a record if it exists else insert it. I already tried previous related answers but those are not sufficient
I have a table name with data_meta
meta_id | token | meta_key | meta_value
1 1 terms_conditions terms conditions content
2 1 is_config_enable 1
3 2 terms_conditions terms conditions content
I have to update based on token & meta_key.. For same token meta_key doesn't repeat..
My Insert Query
"INSERT INTO data_meta (token, meta_key, meta_value)
VALUES (" . $token . ", '" . $key . "', '" . $value . "')";
My Update Query
"UPDATE data_meta SET meta_value = '" . $value . "' WHERE meta_key = '" . $key . "' AND token=" . $token ;