Adds phpdoc comments
parent
9562a7d0bb
commit
396b449bf2
|
@ -1,13 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class Platform
|
||||
*
|
||||
* Handles platform management in the database, including retrieving, adding, editing, and deleting platforms.
|
||||
*/
|
||||
class Platform {
|
||||
/**
|
||||
* @var PDO|null $db The database connection instance.
|
||||
*/
|
||||
private $db;
|
||||
|
||||
/**
|
||||
* Platform constructor.
|
||||
*
|
||||
* @param Database $database The database connection object.
|
||||
*/
|
||||
public function __construct($database) {
|
||||
$this->db = $database->getConnection();
|
||||
}
|
||||
|
||||
// get details of a specified platform ID (or all)
|
||||
/**
|
||||
* Retrieve details of a specific platform or all platforms.
|
||||
*
|
||||
* @param string $platform_id The ID of the platform to retrieve details for (optional).
|
||||
*
|
||||
* @return array An associative array containing platform details.
|
||||
*/
|
||||
public function getPlatformDetails($platform_id = '') {
|
||||
$sql = 'SELECT * FROM platforms';
|
||||
if ($platform_id !== '') {
|
||||
|
@ -23,7 +42,16 @@ class Platform {
|
|||
return $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
// add new platform
|
||||
/**
|
||||
* Add a new platform to the database.
|
||||
*
|
||||
* @param array $newPlatform An associative array containing the details of the new platform:
|
||||
* - `name` (string): The name of the platform.
|
||||
* - `jitsi_url` (string): The URL for the Jitsi integration.
|
||||
* - `jilo_database` (string): The database name for Jilo integration.
|
||||
*
|
||||
* @return bool|string True if the platform was added successfully, or an error message on failure.
|
||||
*/
|
||||
public function addPlatform($newPlatform) {
|
||||
try {
|
||||
$sql = 'INSERT INTO platforms
|
||||
|
@ -45,7 +73,17 @@ class Platform {
|
|||
}
|
||||
}
|
||||
|
||||
// edit an existing platform
|
||||
/**
|
||||
* Edit an existing platform in the database.
|
||||
*
|
||||
* @param int $platform_id The ID of the platform to update.
|
||||
* @param array $updatedPlatform An associative array containing the updated platform details:
|
||||
* - `name` (string): The updated name of the platform.
|
||||
* - `jitsi_url` (string): The updated Jitsi URL.
|
||||
* - `jilo_database` (string): The updated Jilo database name.
|
||||
*
|
||||
* @return bool|string True if the platform was updated successfully, or an error message on failure.
|
||||
*/
|
||||
public function editPlatform($platform_id, $updatedPlatform) {
|
||||
try {
|
||||
$sql = 'UPDATE platforms SET
|
||||
|
@ -70,7 +108,13 @@ class Platform {
|
|||
}
|
||||
}
|
||||
|
||||
// delete a platform
|
||||
/**
|
||||
* Delete a platform from the database.
|
||||
*
|
||||
* @param int $platform_id The ID of the platform to delete.
|
||||
*
|
||||
* @return bool|string True if the platform was deleted successfully, or an error message on failure.
|
||||
*/
|
||||
public function deletePlatform($platform_id) {
|
||||
try {
|
||||
$sql = 'DELETE FROM platforms
|
||||
|
|
Loading…
Reference in New Issue