简体   繁体   中英

Convert to laravel

I want to use laravel for my expert system and i try this code from another website for training, how to convert this code:

$sql = "SELECT GROUP_CONCAT(b.kode_penyakit), a.bobot
        FROM pengetahuan a
        JOIN penyakit b ON a.id_penyakit=b.id_penyakit
        WHERE a.id_gejala IN(".implode(',',$_POST['evidence']).") 
        GROUP BY a.id_gejala";
    $result=$db->query($sql);
    $evidence=array();
    while($row=$result->fetch_row()){
        $evidence[]=$row;
    }

to laravel 8?

DB::table('pengetahuan')
->Join('penyakit','penyakit.id_penyakit','=','pengetahuan.id_penyakit')
->whereIn('pengetahuan.id_gejala',['.implode(',',$_POST['evidence']).'])
->select(DB::raw('GROUP_CONCAT(penyakit.kode_penyakit)'),'pengetahuan.bobot')
->groupBy('pengetahuan.id_gejala')
->get();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM