I trying to use Laravel count() function to get the count of row. I have below code to count the number of row of 2 join table.
Example 1:
$row = DB::table('log_user_login')
->select(DB::raw('log_user_login.Password as LogPassword'), 'user.*')
->join('user', 'log_user_login.Username', '=', 'user.Username')
->where('log_user_login.LoginSession', '!=', '')
->groupBy('user.ID')
->get();
$count = sizeof($row);
Example 2:
$count = DB::table('log_user_login')
->select(DB::raw('log_user_login.Password as LogPassword'), 'user.*')
->join('user', 'log_user_login.Username', '=', 'user.Username')
->where('log_user_login.LoginSession', '!=', '')
->groupBy('user.ID')
->count();
When I echo $count form Example 1, the number of $count is 15415. But $count of Example 2 return me 89. May I know why this happen and how can I get the number of row without using the get()?