HTML and CSS Reference
In-Depth Information
Complete the preceding steps with the query shown in the following bold code, which is added to
class.room_model.inc.php :
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,
);
}
/**
* Retrieves details about a given room
*
* @param $room_id int The ID of the room being checked
* @return array An array of data about the room
*/
public function get_room_data( $room_id )
{
$sql = "SELECT
rooms.id AS room_id,
presenters.id AS presenter_id,
rooms.name AS room_name,
presenters.name AS presenter_name,
email, is_active
FROM rooms
LEFT JOIN room_owners
ON( rooms.id = room_owners.room_id )
LEFT JOIN presenters
ON( room_owners.presenter_id = presenters.id )
WHERE rooms.id = :room_id
LIMIT 1";
$stmt = self::$db->prepare($sql);
$stmt->bindParam(':room_id', $room_id, PDO::PARAM_INT);
$stmt->execute();
$room_data = $stmt->fetch(PDO::FETCH_OBJ);
$stmt->closeCursor();
return $room_data;
}
}
Adding Form Handlers to the Room Controller
The final step in the back end of the app is to add the form actions and action handlers to the Room controller.
 
Search WWH ::




Custom Search