Home > Back-end >  How do I access only the value from the object returned in the variable through a query?
How do I access only the value from the object returned in the variable through a query?

Time:11-06

array(1) { [0]=> object(stdClass)#471 (1) { ["COUNT(*)"]=> int(209) } } This is the value I am getting in a variable. When I am trying to print this it says string cant be converted. From the controller when I pass this variable it doesn't print at the blade page. I know this might be an easy solution but I am not getting on the answer on the internet for this one.

$val = DB::select('select count(*) from stud where (Select sum(eng french german)/3 >3.5)');

Any help would be appreciated :)

CodePudding user response:

$count = DB::table('stud')
    ->whereRaw('((eng   french   german) / 3) > 3.5')
    ->count();
  • Related