php - Sum up function in laravel -


i wanted sum numofunit , total price in subject table. did told on google, still encountered errors vague me. wanted know if doing right, since still new in querying db in laravel. not sure of syntax

this snippet of query:

 $results = db::table('subjects')             ->join('subjectblocking', 'subjects.subjectcode', '=', 'subjectblocking.subjectcode')             ->join('grades', 'subjectblocking.blockcode', '=', 'grades.blockcode')             ->select('subjects.numofunit total_units, subjects.price total_tuition')             ->sum('subjects.numofunit','subjects.price')             ->orwhere(function($query)             {                 $query->where('grades.studentid', '=', '2013-f0218')                         ->where('sem', '=', '1')                         ->where('sy', '=', '2013-2014');             })             ->get(); 

this error have encountered:

call member function orwhere() on non-object on line 72: ->orwhere(function($query)

i believe declared $query, i'm not sure why i'm still receiving errors

the sum needs go after of clauses. move after orwhere, remove superfluous get, , should work... according rest of query formed, looks okay @ first clance @ least.


Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -