HTML and CSS Reference
In-Depth Information
Closing a Room
Closing a room is the same process as opening one, except that the is_active column is set to 0 in the rooms table.
Insert the following bold code into Room_Model :
public function open_room( $room_id )
{
$sql = "UPDATE rooms SET is_active=1 WHERE id = :room_id";
$stmt = self::$db->prepare($sql);
$stmt->bindParam(':room_id', $room_id, PDO::PARAM_INT);
$stmt->execute();
$stmt->closeCursor();
return array(
'room_id' => $room_id,
);
}
/**
* Sets a given room's status to "closed"
*
* @param $room_id int The ID of the room being checked
* @return array An array of data about the room
*/
public function close_room( $room_id )
{
$sql = "UPDATE rooms SET is_active=0 WHERE id = :room_id";
$stmt = self::$db->prepare($sql);
$stmt->bindParam(':room_id', $room_id, PDO::PARAM_INT);
$stmt->execute();
$stmt->closeCursor();
return array(
'room_id' => $room_id,
);
}
}
Loading Room Information
To load a room's information is arguably the most complex query in the app. It requires the following:
room_owners table to the rooms table; then joining the presenters table to that to
make a complete dataset
Joining the
id , name , and is_active columns from the rooms table
Loading the
id to room_id and name to room_name
Renaming
id , name , and email columns from the presenters table
Loading the
id to presenter_id and name to presenter_name
Renaming
 
Search WWH ::




Custom Search