<?php

use Battles\GameConfigs;

/**
 * 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
            )
                // Выбор базы данных
                ->setDatabaseName(GameConfigs::DATABASE_NAME)
                // Выбор кодировки
                ->setCharset(GameConfigs::DATABASE_CHARSET);
        }
        return self::$_instance;
    }
}