php - Laravel 5.2 shows "The Response content must be a string or object implementing __toString(), "boolean" given" when I try to use DB::statement -


i'm trying use db::statement() method run sql, can't work , shows "unexpectedvalueexception in response.php line 395: response content must string or object implementing __tostring(), "boolean" given."

here's code:

$students = db::statement('select stu_agency,avg(stu_rank1) avggrade students group stu_agency'); return $students; 

from docs:

some database statements should not return value. these types of operations, may use statement method on db facade.

you searching for

$students = db::table('students')                   ->select('stu_agency', db::raw('avg(stu_rank1) avggrade'))                   ->groupby('stu_agency')                   ->get(); return $students; 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -