OK, my problem is that I have a script that loads on every page, it checks if a signed in user is banned or not by checking a column named "banned" that can output either 0 (not banned) or 1 (banned). I've tried searching for this, but didn't find an absolute answer to which performs better:
Fetching a COUNT(*) query:
$query = $PDO->prepare("SELECT COUNT(*) FROM users WHERE id = :ID AND banned = 1");
$query->execute(array(":ID" => $USER_ID));
if ($query->fetchColumn() > 0) {
// USER IS BANNED! SHOW ERROR MESSAGE!
}
Using rowCount() instead of fetching:
$query = $PDO->prepare("SELECT banned FROM users WHERE id = :ID AND banned = 1");
$query->execute(array(":ID" => $USER_ID));
if ($query->rowCount() > 0) {
// USER IS BANNED! SHOW ERROR MESSAGE!
}