I have a follow system that allow user to follow one another. I'm using php pdo so it doesn't support multiple line query instead I need a long query. Currently I'm using the code below
$query = $db->query("SELECT id FROM follow WHERE user1 = 'kim' AND user2 = 'tim' ");
if($query->rowCount() > 0 ){
$db->query("DELETE * FROM follow WHERE user1 = 'kim' AND user2 = 'tim' ");
}else{
$db->query("INSERT INTO follow (user1,user2) VALUES ('kim','tim') ");
}
So here what I want is a long query rather than multiple query statement. Additional with the long query I need get the data that indicate wether the record is insert or delete.(Maybe this question is duplicated but this is the part that wasn't duplicated) How can I acheive it?