public function addImageMatchEntryForLocation($gameId, $intLocationId, $intMatchMediaID) { //Check if location exists, and store code $query = "SELECT * FROM qrcodes WHERE game_id = {$gameId} AND link_id={$intLocationId}"; $result = Module::query($query); $code = 0; if (mysql_num_rows($result) != 0) { $row = mysql_fetch_object($result); $code = $row->code; } else { return new returnData(1, NULL, "Location Doesn't Exist"); } //Check if this media/location pair already exists. If so, exit (our job is already done) $query = "SELECT * FROM qrcodes WHERE game_id = {$gameId} AND link_id ={$intLocationId} AND match_media_id ={$intMatchMediaID}"; $result = Module::query($query); if (mysql_num_rows($result) != 0) { return new returnData(0); } //Check if this is the only entry... $query = "SELECT * FROM qrcodes WHERE game_id = {$gameId} AND link_id ={$intLocationId} AND match_media_id ='0'"; $result = Module::query($query); if (mysql_num_rows($result) == 1) { $query = "UPDATE qrcodes SET match_media_id = {$intMatchMediaID} WHERE game_id = {$gameId} AND link_id={$intLocationId}"; Module::query($query); Locations::generateDescriptors($intMatchMediaID, $gameId); return new returnData(0); } $query = "INSERT INTO qrcodes (game_id, link_id, match_media_id, code) VALUES ({$gameId}, {$intLocationId}, {$intMatchMediaID}, {$code})"; Module::query($query); Locations::generateDescriptors($intMatchMediaID, $gameId); return new returnData(0); }