dimanche 27 décembre 2015

Laravel Error Syntax error or access violation in DB::raw

I want to get agama with the count of pegawai with same as propinsisID and agamaID this is my controller, but i get this error Error Syntax error or access violation Please help me.. Sorry for Bad English

public function getPropinsi($id)
{
    $this->data['query'] =  DB::table("propinses")->where("id",$id)->first();
    $this->data['title'] = $this->data['query']->Propinsi;
    $this->data['count_satker'] = DB::table('satkerfakes')->where('PropinsiID',$id)->count(); 
    $this->data['pegawai'] = Pegawais::where('PropinsiID',$id);
    $this->data['agama'] = DB::table("agamas")
                                    ->select("agamas.Agama",DB::raw("(select count(*) 
                                        from pegawais 
                                        where pegawais.PropinsiID = $id
                                        where pegawais.AgamaID = agamas.AgamaID) as total_pegawai"))->get();
    return view('index.propinsi',$this->data);
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire