function store() { global $mainframe, $db, $user; $post = $_POST; $arr_team_table = Request::getVar('arr_team_table', null); $arr_team_table = json_decode($arr_team_table, true); $model = Tournament::getInstance(); global $user; if (!$user->isSuperAdmin()) { YiiMessage::raseNotice("Your account not have permission to change Tournament"); $this->redirect(Router::buildLink("gamesport", array('view' => 'tournament'))); } $tourID = Request::getVar('tourID', 0); $db = Yii::app()->db; foreach ($arr_team_table as $table_num => $team_tables) { if (count($team_tables)) { $stt = 1; foreach ($team_tables as $teamID => $team) { if ($team == null) { continue; } if ($team['ordering'] == null or $team['ordering'] == 0) { $team['ordering'] = $stt; } $query = "UPDATE " . TBL_GS_TEAM_REGISTER_TOUR . " SET table_num = {$table_num}" . " ,ordering = " . $team['ordering'] . " ,mdate = now()" . " ,modified_by = {$user->id}" . " WHERE tourID = {$tourID} AND teamID = {$teamID}"; $command = $db->createCommand($query); $command->execute(); $stt++; } } } return true; }