Query builder with 4 tables [duplicate]
This question already has an answer here:
This is my query builder function :
public function MonthSoldGDV($dev,$year){
$monthlyGDV = DB::table('pams_unit')
->join('pams_phase','pams_unit.phase_id','pams_phase.phase_id')
->join('pams_project','pams_phase.project_id','pams_project.project_id')
->join('pams_developer','pams_project.dev_id ','pams_developer.id')
->select('pams_developer.developer_name')
->selectRaw('year(pams_unit.sold_date) as year')
->selectRaw('month(pams_unit.sold_date) as month')
->selectRaw('sum(pams_unit.sold_price) as gdv')
->where('pams_developer.developer_name','$dev')
->whereRaw('year(sold_date) = $year')
->groupBy('month')
->get();
return $monthlyGDV;
}
But it show an error Column not found: 1054 Unknown column '$year' in 'where clause'
Can someone help me to figure out my problem ?
from Laravel Questions and Answers https://laravelquestions.com/php/query-builder-with-4-tables-duplicate/
via Lzo Media
No comments:
Post a Comment