vendredi 3 février 2017

how to update multiple rows with multiple values using QueryBuilder?

I want to update single column(index_order) in multiple rows with multiple values, How can I do? Here is My code:

 public function changeIndexOrder() {

$taskIdsArray = ["426","537","556","557","559","653","584","655","656","664","666","671","677"]
$orderIndex =   ["1","2","3","4","5","6","7","8","9","10","11","12","13"]

 DB::table('task_manages')->whereIn('id', $taskIdsArray)->update('index_order' ,$orderIndex);

}

For example where id=426 then update index_order Column with value of '1' , and if id=537 then update index_order with '2'.

Please let me know how can I do this with single update query?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2l3xk91
via IFTTT

Aucun commentaire:

Enregistrer un commentaire