Started building page cleanup Modified code pools Backported layout/blocks/templates 3-step view system Reforged Overview page Moved graphics, added topnav template, fixed number render bug Added BCMath optionnal usage Updated BC Math comparison for capped resources Fixed planet resource production updates Various additions Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
34 lines
No EOL
1.1 KiB
PHP
34 lines
No EOL
1.1 KiB
PHP
<?php
|
|
|
|
class Legacies_Database
|
|
extends PDO
|
|
{
|
|
protected static $_singleton = null;
|
|
|
|
protected static $_prefix = null;
|
|
|
|
public static function getSingleton()
|
|
{
|
|
if (self::$_singleton === null) {
|
|
$config = include ROOT_PATH . 'config.php';
|
|
$hostname = $config['global']['database']['options']['hostname'];
|
|
$username = $config['global']['database']['options']['username'];
|
|
$password = $config['global']['database']['options']['password'];
|
|
$database = $config['global']['database']['options']['database'];
|
|
|
|
self::$_singleton = new self("mysql:dbname={$database};host={$hostname}", $username, $password, array(
|
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
|
));
|
|
}
|
|
return self::$_singleton;
|
|
}
|
|
|
|
public function getTable($name)
|
|
{
|
|
if (self::$_prefix === null) {
|
|
$config = include ROOT_PATH . 'config.php';
|
|
self::$_prefix = $config['global']['database']['table_prefix'];
|
|
}
|
|
return self::$_prefix . $name;
|
|
}
|
|
} |