How to do update query on laravel fluent using db::raw

后端 未结 3 1981
故里飘歌
故里飘歌 2020-12-14 15:11

This is related to one of my question earlier where:

Update table1 field with table2 field value in join laravel fluent

But since this is a different approac

相关标签:
3条回答
  • 2020-12-14 15:36
    DB::statement("UPDATE favorite_contents, contents SET favorite_contents.type = contents.type where favorite_contents.content_id = contents.id");
    

    Try DB::statement for raw queries that does not involve outputting something (select).

    0 讨论(0)
  • 2020-12-14 15:42

    code raw updates like this:

    ...->update( array(
        'column' => DB::raw( 'column * 2' )
    ) );
    
    0 讨论(0)
  • 2020-12-14 15:54

    And will be work such similar, simple realization in Laravel 5.2 , Query Builder:

    DB::table('stores')
                ->where('id', $request)
                ->update(['visibility' =>DB::raw($value)]);
    

    This response is tested real site and working properly

    0 讨论(0)
提交回复
热议问题