Adds phpdoc comments
parent
51282eae38
commit
9562a7d0bb
|
@ -2,11 +2,12 @@
|
|||
|
||||
/**
|
||||
* Class Database
|
||||
*
|
||||
* Manages database connections for SQLite and MySQL (or MariaDB).
|
||||
*/
|
||||
class Database {
|
||||
/**
|
||||
* @var PDO|null $pdo The PDO instance representing the database connection.
|
||||
* @var PDO|null $pdo The database connection instance.
|
||||
*/
|
||||
private $pdo;
|
||||
|
||||
|
|
|
@ -1,13 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Class Host
|
||||
*
|
||||
* Manages the hosts in the database, providing methods to retrieve, add, edit, and delete host entries.
|
||||
*/
|
||||
class Host {
|
||||
/**
|
||||
* @var PDO|null $db The database connection instance.
|
||||
*/
|
||||
private $db;
|
||||
|
||||
/**
|
||||
* Host constructor.
|
||||
*
|
||||
* @param Database $database The database connection object.
|
||||
*/
|
||||
public function __construct($database) {
|
||||
$this->db = $database->getConnection();
|
||||
}
|
||||
|
||||
// get details of a specified host ID (or all) in a specified platform ID
|
||||
/**
|
||||
* Get details of a specified host ID (or all hosts) in a specified platform ID.
|
||||
*
|
||||
* @param string $platform_id The platform ID to filter the hosts by (optional).
|
||||
* @param string $host_id The host ID to filter the details (optional).
|
||||
*
|
||||
* @return array The details of the host(s) in the form of an associative array.
|
||||
*/
|
||||
public function getHostDetails($platform_id = '', $host_id = '') {
|
||||
$sql = 'SELECT
|
||||
id,
|
||||
|
@ -41,7 +61,13 @@ class Host {
|
|||
}
|
||||
|
||||
|
||||
// add new host
|
||||
/**
|
||||
* Add a new host to the database.
|
||||
*
|
||||
* @param array $newHost An associative array containing the details of the host to be added.
|
||||
*
|
||||
* @return bool True if the host was added successfully, otherwise false.
|
||||
*/
|
||||
public function addHost($newHost) {
|
||||
try {
|
||||
$sql = 'INSERT INTO hosts
|
||||
|
@ -64,7 +90,14 @@ class Host {
|
|||
}
|
||||
}
|
||||
|
||||
// edit an existing host
|
||||
/**
|
||||
* Edit an existing host in the database.
|
||||
*
|
||||
* @param string $platform_id The platform ID to which the host belongs.
|
||||
* @param array $updatedHost An associative array containing the updated details of the host.
|
||||
*
|
||||
* @return bool True if the host was updated successfully, otherwise false.
|
||||
*/
|
||||
public function editHost($platform_id, $updatedHost) {
|
||||
try {
|
||||
$sql = 'UPDATE hosts SET
|
||||
|
@ -90,7 +123,13 @@ class Host {
|
|||
}
|
||||
|
||||
|
||||
// delete a host
|
||||
/**
|
||||
* Delete a host from the database.
|
||||
*
|
||||
* @param int $host_id The ID of the host to be deleted.
|
||||
*
|
||||
* @return bool True if the host was deleted successfully, otherwise false.
|
||||
*/
|
||||
public function deleteHost($host_id) {
|
||||
try {
|
||||
$sql = 'DELETE FROM hosts
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
/**
|
||||
* Class Log
|
||||
*
|
||||
* Handles logging events into a database and reading log entries.
|
||||
*/
|
||||
class Log {
|
||||
/**
|
||||
* @var PDO $db The database connection instance.
|
||||
* @var PDO|null $db The database connection instance.
|
||||
*/
|
||||
private $db;
|
||||
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
/**
|
||||
* Class Server
|
||||
*
|
||||
* Handles server-related operations, including retrieving server status.
|
||||
*/
|
||||
class Server {
|
||||
/**
|
||||
* @var PDO|null The database connection instance.
|
||||
* @var PDO|null $db The database connection instance.
|
||||
*/
|
||||
private $db;
|
||||
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
/**
|
||||
* Class User
|
||||
*
|
||||
* Handles user-related functionalities such as registration, login, rights management, and profile updates.
|
||||
*/
|
||||
class User {
|
||||
/**
|
||||
* @var PDO Database connection instance.
|
||||
* @var PDO|null $db The database connection instance.
|
||||
*/
|
||||
private $db;
|
||||
|
||||
|
|
Loading…
Reference in New Issue