Home > OS >  How To Convert dot(.) To String In Laravel with Mysql Querry's function whereColumn
How To Convert dot(.) To String In Laravel with Mysql Querry's function whereColumn

Time:06-13

I Have this kind of error ,in subid i have . inside the argument that laravel automatically place an ' after that.how can i get rid of that or how can i convert my . to not to be string concatenate expression and convert it to become string instead ?

here is my Controller Code which have the syntax :

 public function datavolumechart(){
    $volume = lokasipekerjaan::select(
        DB::raw("YEAR(tanggal) as year"),
        DB::raw("SUM(volume) as total_volume
        "),
    )->havingRaw('total_volume < 100000000', [1])->whereColumn('subid','1.A.A.1')->orderBy(DB::raw("WEEK(tanggal)"))
    ->groupBy(DB::raw("WEEK(tanggal)"))
    ->pluck('total_volume','year');

            return view('admin.home',compact('volume'));
}

CodePudding user response:

Can you try change to this

->whereColumn('subid',`1.A.A.1`)

CodePudding user response:

i think i just wrote false msyql syntax,what i need to do is just : erase ->havingRaw('total_volume < 100000000', [1]) and ->whereColumn,To match a value then i just need to use ->where('subid', '1.A.A.1')

public function datavolumechart(){
$string = '1.A.A.1';
$volume = lokasipekerjaan::select(
    DB::raw("YEAR(tanggal) as year"),
    DB::raw("SUM(volume) as total_volume
    "),
)->where('subid','LIKE','%'.$string.'%')->orderBy(DB::raw("WEEK(tanggal)"))
    ->groupBy(DB::raw("WEEK(tanggal)"))
    ->pluck('total_volume','year');

        return view('admin.home',compact('volume'));

}

  • Related