01-13-2019, 01:50 PM
(01-13-2019, 01:37 PM)LBC Wrote: Mudmin? Any thoughts on this?
Sorry. I missed that post. Help me understand the goal of this so I can help write that query.
What do you want to do with the regular days and random days?
Your friend doesn't understand that our $db->query thing protects you from the "killing the db" thing he's talking about. That's what the ? are for.
Regarding this query...
$count = $db->query("SELECT regular_days AND random_days FROM users WHERE regular_days= '?' OR random_days= '?'",array($days))->count();
What does days refer to? is it a number?
->count(); is going to give you back the NUMBER OF ROWS that were affected by that query. So if Sunday is a 1 and you wanted to know how many people have a 1 in either random days or regular days, the query would be
$count = $db->query("SELECT id FROM users WHERE regular_days= ? OR random_days= ?",array($days,$days))->count();
I selected id because the only thing you're returning from that query is the number of rows...not the actual data itself.
If you haven't watched it, I think this video could help a ton on understanding what all these ?, count, results, first do.
https://www.youtube.com/watch?v=rb0kD5tCENM