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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -