Added phpDoc comments
This commit is contained in:
parent
fcb80c9f32
commit
3c45bbf4d1
@ -4,6 +4,13 @@ namespace Lychee\Modules;
|
|||||||
|
|
||||||
final class Config {
|
final class Config {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the configuration file.
|
||||||
|
* @return true|string Returns true when successful.
|
||||||
|
* Warning: Connection failed!
|
||||||
|
* Warning: Creation failed!
|
||||||
|
* Warning: Could not create file!
|
||||||
|
*/
|
||||||
public static function create($host, $user, $password, $name = 'lychee', $prefix = '') {
|
public static function create($host, $user, $password, $name = 'lychee', $prefix = '') {
|
||||||
|
|
||||||
// Open a new connection to the MySQL server
|
// Open a new connection to the MySQL server
|
||||||
@ -25,8 +32,6 @@ final class Config {
|
|||||||
// Save config.php
|
// Save config.php
|
||||||
$config = "<?php
|
$config = "<?php
|
||||||
|
|
||||||
if(!defined('LYCHEE')) Response::error('Direct access is not allowed!');
|
|
||||||
|
|
||||||
// Database configuration
|
// Database configuration
|
||||||
\$dbHost = '$host'; // Host of the database
|
\$dbHost = '$host'; // Host of the database
|
||||||
\$dbUser = '$user'; // Username of the database
|
\$dbUser = '$user'; // Username of the database
|
||||||
|
@ -16,6 +16,9 @@ final class Database {
|
|||||||
'030003' // 3.0.3
|
'030003' // 3.0.3
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return object Returns a new or cached connection.
|
||||||
|
*/
|
||||||
public static function get() {
|
public static function get() {
|
||||||
|
|
||||||
if (!self::$instance) {
|
if (!self::$instance) {
|
||||||
@ -36,6 +39,10 @@ final class Database {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits on error.
|
||||||
|
* @return boolean Returns true when successful.
|
||||||
|
*/
|
||||||
private function __construct($host, $user, $password, $name = 'lychee', $dbTablePrefix) {
|
private function __construct($host, $user, $password, $name = 'lychee', $dbTablePrefix) {
|
||||||
|
|
||||||
// Check dependencies
|
// Check dependencies
|
||||||
@ -63,8 +70,13 @@ final class Database {
|
|||||||
|
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return object|false Returns the connection when successful.
|
||||||
|
*/
|
||||||
public static function connect($host = 'localhost', $user, $password) {
|
public static function connect($host = 'localhost', $user, $password) {
|
||||||
|
|
||||||
// Open a new connection to the MySQL server
|
// Open a new connection to the MySQL server
|
||||||
@ -77,6 +89,9 @@ final class Database {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean Returns true when successful.
|
||||||
|
*/
|
||||||
private static function setCharset($connection) {
|
private static function setCharset($connection) {
|
||||||
|
|
||||||
// Check dependencies
|
// Check dependencies
|
||||||
@ -95,6 +110,9 @@ final class Database {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean Returns true when successful.
|
||||||
|
*/
|
||||||
public static function createDatabase($connection, $name = 'lychee') {
|
public static function createDatabase($connection, $name = 'lychee') {
|
||||||
|
|
||||||
// Check dependencies
|
// Check dependencies
|
||||||
@ -113,6 +131,9 @@ final class Database {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean Returns true when successful.
|
||||||
|
*/
|
||||||
private static function createTables($connection) {
|
private static function createTables($connection) {
|
||||||
|
|
||||||
// Check dependencies
|
// Check dependencies
|
||||||
@ -238,6 +259,10 @@ final class Database {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exits when an update fails.
|
||||||
|
* @return boolean Returns true when successful.
|
||||||
|
*/
|
||||||
private static function update($connection, $dbName) {
|
private static function update($connection, $dbName) {
|
||||||
|
|
||||||
// Check dependencies
|
// Check dependencies
|
||||||
@ -267,6 +292,9 @@ final class Database {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean Returns true when successful.
|
||||||
|
*/
|
||||||
public static function setVersion($connection, $version) {
|
public static function setVersion($connection, $version) {
|
||||||
|
|
||||||
// Check dependencies
|
// Check dependencies
|
||||||
@ -276,9 +304,13 @@ final class Database {
|
|||||||
$result = self::execute($connection, $query, __METHOD__, __LINE__);
|
$result = self::execute($connection, $query, __METHOD__, __LINE__);
|
||||||
|
|
||||||
if ($result===false) return false;
|
if ($result===false) return false;
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string Returns a escaped query.
|
||||||
|
*/
|
||||||
public static function prepare($connection, $query, array $data) {
|
public static function prepare($connection, $query, array $data) {
|
||||||
|
|
||||||
// Check dependencies
|
// Check dependencies
|
||||||
@ -345,6 +377,9 @@ final class Database {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return object|false Returns the results on success.
|
||||||
|
*/
|
||||||
public static function execute($connection, $query, $function, $line) {
|
public static function execute($connection, $query, $function, $line) {
|
||||||
|
|
||||||
// Check dependencies
|
// Check dependencies
|
||||||
|
Loading…
Reference in New Issue
Block a user