Q:

Rows number check in PHP

I am trying to check if there were any records (more than 0) in my database table:
        $ifExists = DB::select('SELECT COUNT(*) FROM `characters` WHERE userid = ?', array(Auth::id()));

Now I am checking if there are more than 0:
   if($ifExists > 0){
                return Redirect('/board');
            }
            else{
                return view('intro');
            }

It always takes me to the /board. But there are many rows in this database table.
The echo $ifExists; shows me [{"COUNT(*)":0}]
How do I check this number? 

A:

Try it this way:
$ifExists = DB::table('characters')->where('userid', Auth::id())->count();

If you do it like in your question, you will receive an array of objects.
If you only want to check for existens of entries and do not need the count, you can just use the exists() function whitch will return you a boolean:
$ifExists = DB::table('characters')->where('userid', Auth::id())->exists();

if($ifExists){
    return Redirect('/board');
}else{
    return view('intro');
}

