Matslom
235
21
Laravel

Update multiple rows using Query Builder (1 query)

Posted 3 years ago by Matslom

Hello, it is possible to update multiple rows in 1 query? I tried something like this

$where['page_id'] = [1,2,3];
$update = [['column' => 'value1'],['column' => 'value2']];
DB::table('my_table')->where($where)->update($update);

but only what I get was Parameter mismatch, pattern is a string while replacement is an array error.

Thanks.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.