I have this website where I a user can create so many posts a day called 'clippets' and before I check the limit, I've used some SQL to get the total number of 'clippets' in the current day.
So let's say I only want to allow users to make 20 'clippets' a day, not based on time though only the day, as if I were to base it on the last 24 hours it would be like the user is chasing the limit all the time...
Anyway, here is my SQL:
$date = date("Y-m-d");
$sql = "SELECT COUNT(id) FROM clippets WHERE userID = ? AND DATE(createdAt) = '$date'; ";
My question is... Is this a slow way to approach this, using the PHP date function and then using that within the SQL query, does it treat them as strings or? Because the createdAt field is a datetime data type, so does MySQL convert both dates to strings and then compare? Is that a slow way of doing this?