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
Post a Comment