PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table stage_1 ( tournament_id int, team_id int, group_id int, points int );
Copy Clear
Copy Format Clear
<?php $data = [ [ 'tournament_id' => 1, 'team_id' => 1, 'group_id' => 1, 'points' => 1 ], [ 'tournament_id' => 1, 'team_id' => 2, 'group_id' => 1, 'points' => 1 ], ]; $db::beginTransaction(); try { foreach ($data as $d) { $db::table('stage_1') ->where('tournament_id', $d['tournament_id']) ->where('team_id', $d['team_id']) ->where('group_id', $d['group_id']) ->update(['points' => $d['points']]); } $db::commit(); } catch (\Exception $e) { $db::rollback(); }
Show:  
Copy Clear