battles/classes/Database/db.php

39 lines
912 B
PHP
Raw Normal View History

2018-01-28 16:40:49 +00:00
<?php
use Battles\GameConfigs;
2018-01-28 16:40:49 +00:00
/**
* Created by PhpStorm.
* User: lopiu
* Date: 28.01.2018
* Time: 16:35
*/
class db
{
private static $_instance = null;
private function __clone() {}
private function __construct() {}
/**
* @return \Krugozor\Database\Mysql\Mysql
*/
public static function c()
{
if (!self::$_instance)
{
self::$_instance = Krugozor\Database\Mysql\Mysql::create(
GameConfigs::DATABASE_HOST,
GameConfigs::DATABASE_USER,
GameConfigs::DATABASE_PASS,
GameConfigs::DATABASE_PORT
)
2018-01-28 16:40:49 +00:00
// Выбор базы данных
->setDatabaseName(GameConfigs::DATABASE_NAME)
2018-01-28 16:40:49 +00:00
// Выбор кодировки
->setCharset(GameConfigs::DATABASE_CHARSET);
2018-01-28 16:40:49 +00:00
}
return self::$_instance;
}
}