Home > Software engineering >  How to convert dot (.) to string in Laravel with Mysql query's function whereColumn
How to convert dot (.) to string in Laravel with Mysql query's function whereColumn

Time:06-14

I have this kind of error in a subid I have. In 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