HTML and CSS Reference
In-Depth Information
$stmt = self::$db->prepare($sql);
$stmt->bindParam(':email', $email, PDO::PARAM_STR, 255);
$stmt->execute();
$pres_id = $stmt->fetch(PDO::FETCH_OBJ)->id;
$stmt->closeCursor();
// Stores the room:presenter relationship
$sql = 'INSERT INTO room_owners (room_id, presenter_id)
VALUES (:room_id, :pres_id)';
$stmt = self::$db->prepare($sql);
$stmt->bindParam(":room_id", $room_id, PDO::PARAM_INT);
$stmt->bindParam(":pres_id", $pres_id, PDO::PARAM_INT);
$stmt->execute();
$stmt->closeCursor();
return array(
'room_id' => $room_id,
);
}
}
Checking to See Whether a Room Exists
As part of the process of joining a room, the Room controller needs to be able to verify that a room exists. This method
simply selects the COUNT() of rooms in the rooms table matching the given ID; a count of 1 means the room exists, and
0 means it does not.
Add the following bold code to Room_Model :
// Stores the room:presenter relationship
$sql = 'INSERT INTO room_owners (room_id, presenter_id)
VALUES (:room_id, :pres_id)';
$stmt = self::$db->prepare($sql);
$stmt->bindParam(":room_id", $room_id, PDO::PARAM_INT);
$stmt->bindParam(":pres_id", $pres_id, PDO::PARAM_INT);
$stmt->execute();
$stmt->closeCursor();
return array(
'room_id' => $room_id,
);
}
/**
* Checks if a given room exists
*
* @param $room_id int The ID of the room being checked
* @return bool Whether or not the room exists
*/
public function room_exists( $room_id )
{
// Loads the number of rooms matching the provided room ID
 
Search WWH ::




Custom Search