php - Getting value from query builder select count result in Laravel
I have a query builder in Laravel controller to get total value of total select table row from database, and I want to get the result value, but the result always give me an array result, and I've tried to access the value from the array but I still cant get the value
Here's the query builder:
$total = DB::select(DB::raw("SELECT COUNT(*) FROM hstmemb WHERE period = '".$bonperiod."' AND totbns <> 0 AND paytype = 'S'"));
$getbonus[0]->total = $total;
The result I get is an array object, but I want to get just the count result in int number.
Answer
Solution:
Use DB table with count function.