I'm using Wordpress and deleting posts from a MYSQL database via PHP using AJAX.
This works great.
The users on my site have the ability to "favourite" posts, this renders a list showing them what they have favourited (basically a separate table that cross references their user ID with the post ID's).
Now the issue is that when a post is deleted, I also need to delete any "favourited" references from the other table.
I'm doing this by running the following query as part of the delete post routine :
$wpdb->query("DELETE FROM favourite_posts WHERE post_id = ".$_REQUEST['id']);
This works perfectly but if I add error checking :
$wpdb->query("DELETE FROM favourite_posts WHERE post_id = ".$_REQUEST['id']) or die(mysql_error());
And the post is NOT in the favourites table the entire routine fails, obviously.
So my question is this...
Will running the first query (without error checking), cause problems / server overload etc when this routine is run on posts that don't also exist in the favourite_posts table? Or does MYSQL just ignore failed requests and carry on as normal?
Or is this bad practice and should I check if the post exists in favourite_posts before attempting to remove it? Obviously this means more queries which I'm hoping to avoid.