$count = $db->query("SELECT COUNT(*) FROM users")->fetchColumn();
OR
$stmt = $db->prepare("SELECT COUNT(*) FROM users WHERE uid=:uid"); $result = $stmt->execute(array(':uid' => $uid)); $count = $stmt->fetchColumn();
OR
$stmt = $db->prepare("SELECT COUNT(*) FROM friends WHERE uid=:uid OR fid=:uid"); $stmt->bindValue(':uid', $uid, PDO::PARAM_INT); $stmt->execute(); $count = $stmt->fetchColumn();