prepare("UPDATE `matchUsers` SET `isReady` = ? WHERE `userID` = ? AND `matchID` = ?"); $stmt->bind_param('iii', $intReadyStatus, $userID, $matchID); $stmt->execute(); return; } // !! function getPlayersForMatch($matchID) { global $mysqli; if (!is_numeric($matchID)) { return false; } $res = $mysqli->query(" SELECT matchUsers.userID, TIME_TO_SEC(TIMEDIFF(NOW(), matchUsers.dateLastChecked)) as secFromLastChecked, matchUsers.isReady, users.displayName as 'display', users.displayColor, users.wallColor, users.wallEmblem, users.wallOrientation, (matches.creatorUserID = users.ID) as `isCreator` FROM `matches` LEFT JOIN `matchUsers` ON matchUsers.matchID = matches.ID LEFT JOIN `users` ON matchUsers.userID = users.ID "); $array = array(); if ($res->num_rows == 0) { $res->close(); return false; } while ($response = $res->fetch_assoc()) { $array['users'][] = $response; } $res->close(); $mysqli->close(); if (count($array) < 1) return false; return $array; } function getMatchStatus($matchID) { global $mysqli; if (!is_numeric($matchID)) return false; //Not sure why this happens; but just return nothing.. if (!is_object($mysqli)) die("mysqli is not an object"); if ($res = $mysqli->query(" SELECT matches.creatorUserID, matches.mapID, matches.isComplete, matches.isStarted, matches.dateCreated, matches.dateExpires, matches.dateStarted, matches.requiredPlayers, matches.secondsGiven, matches.useSmartTime, users.displayName, users.displayColor, users.wallColor, users.wallEmblem, users.wallOrientation FROM `matches` LEFT JOIN `users` ON matches.userID = users.ID WHERE matches.ID = '$matchID' ")) { $array = array(); if ($res->num_rows == 0) { $res->close(); return false; } while ($response = $res->fetch_assoc()) { $array[] = $response; } $res->close(); if (count($array) < 1) return false; return $array; } else { printf("DError: %s\n", $mysqli->error); return false; } } //Returns the matchID function createMatch($creatorID, $requiredPlayers, $secondsGiven, $useSmartTime = false) { global $mysqli; $useSmartTime = intval($useSmartTime); $stmt = $mysqli->prepare("INSERT INTO `matches` (`creatorUserID`, `requiredPlayers`, `secondsGiven`, `useSmartTime`) VALUES (?, ?)"); $stmt->bind_param('iiii', $creatorID, $requiredPlayers, $secondsGiven, $useSmartTime); $stmt->execute(); $ID = $stmt->insert_id; $stmt->close(); return $ID; } ?>