wootook-reloaded/includes/application/code/core/Legacies/Database.php
Gregory PLANCHAT 8f0f7a4d46 Updated themes
Updated buildings
Updated shipyard page (ships & defense)
Added Buildings building queue display & cancel build action.
Added research lab
Added navigation block structure
Removed old code
Updated registration
Added files to .gitignore

Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
2011-09-13 12:54:03 +02:00

39 lines
No EOL
1.3 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'];
$port = 3306;
if (isset($config['global']['database']['options']['port'])) {
$port = $config['global']['database']['options']['port'];
}
self::$_singleton = new self("mysql:dbname={$database};host={$hostname};port={$port}", $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;
}
}