function UpdateTournamentResultsField($connection, $tournamentKey, $field, $value, $paramType) { // Create the record if it does not exist CreateTournamentDetails($connection, $tournamentKey); $sqlCmd = "UPDATE `TournamentDetails` SET `" . $field . "`= ? WHERE `TournamentKey` = ?"; $update = $connection->prepare($sqlCmd); if (!$update) { die($sqlCmd . " prepare failed: " . $connection->error); } if (!$update->bind_param($paramType . 'i', $value, $tournamentKey)) { die($sqlCmd . " bind_param failed: " . $connection->error); } if (!$update->execute()) { die($sqlCmd . " execute failed: " . $connection->error); } $update->close(); }
function UpdateTournamentDetails($connection, $tournamentKey, $field, $value) { // Create the record if it does not exist CreateTournamentDetails($connection, $tournamentKey); switch ($field) { case 'ScoresFile': case 'ScoresPostedDate': case 'ChitsFile': case 'ChitsPostedDate': case 'PoolFile': case 'PoolPostedDate': case 'ClosestToThePinPostedDate': $sqlCmd = "UPDATE `TournamentDetails` SET `" . $field . "` = ? WHERE `TournamentKey` = ?"; $paramType = 's'; break; default: die("Did not provide valid field parameter to UpdateTournamentDetails"); } $update = $connection->prepare($sqlCmd); if (!$update) { die($sqlCmd . " prepare failed: " . $connection->error); } if (!$update->bind_param($paramType . 'i', $value, $tournamentKey)) { die($sqlCmd . " bind_param failed: " . $connection->error); } if (!$update->execute()) { die($sqlCmd . " execute failed: " . $connection->error); } $update->close(); }