示例#1
0
 public function getBRoom($brain_room)
 {
     $pdo = Database::getDB();
     $rid = $brain_room->getRid();
     $room_id = $brain_room->getRoom_id();
     $user_id = $brain_room->getUser_id();
     $stmt = $pdo->prepare("SELECT brain_rooms.category, brain_rooms.players, brain_joinroom.player_type, brain_joinroom.room_num FROM brain_rooms, brain_joinroom  WHERE brain_rooms.room_num = brain_joinroom.room_num AND user_id = ?");
     $stmt->execute(array($user_id));
     $row = $stmt->fetch();
     $brain_room = new brain_Room();
     $brain_room->setRoom_id($row['room_num']);
     $brain_room->setCategory($row['category']);
     $brain_room->setPlayer_type($row['player_type']);
     $brain_room->setPlayers($row['players']);
     // $brain_room->setRoom_id($row['room_num']);
     return $brain_room;
 }
示例#2
0
    header("location:.?action=View_brain_Question&dup=" . urlencode($dup) . "&cid=" . urlencode($_SESSION['cid']) . "&quest=''");
} elseif ($action == 'brain_addRoom') {
    if (isset($_SESSION['user'])) {
        $brain_users = $brain_UserDB->brain_getUser($_SESSION['user']);
    }
    $_SESSION['room_num'] = $_POST['room_num'];
    $_SESSION['user_id'] = $_POST['user_id'];
    $user_id = $_SESSION['user_id'];
    $room_num = $_SESSION['room_num'];
    $_SESSION['category'] = ucwords($_POST['category']);
    $_SESSION['players'] = $_POST['players'];
    $player_type = "Server";
    $num_of_players = 1;
    $brain_room->setRoom_id($_SESSION['room_num']);
    $brain_room->setUser_id($_SESSION['user_id']);
    $brain_room->setCategory($_SESSION['category']);
    $brain_room->setPlayers($_SESSION['players']);
    $brain_room->setPlayer_type($player_type);
    $brain_room->setNum_of_players($num_of_players);
    $brain_roomDB->brain_AddRoom($brain_room);
    $rid = $brain_roomDB->getRid($_SESSION['room_num']);
    $rooms_id = $rid->getRid();
    $player_type = $rid->getPlayer_type();
    $brain_joinRoom->setJid($rooms_id);
    $brain_joinRoom->setUser_id($_SESSION['user_id']);
    $brain_joinRoom->setRoom_num($room_num);
    $brain_joinRoom->setPlayer_type($player_type);
    //--------Reserve Question(Easy)----------------//
    $level = 'Easy';
    $brain_reserveQuestionDB->removeReservedQs($_SESSION['room_num']);
    $getQuestion = $brain_QuestionDB->getRandQuestion($level, $_SESSION['category']);