1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace app\models;
- class Doctrine
- {
- private static $config = [
- 'test' => [
- 'host' => 'dmatter.net',
- 'db' => 'promsystem_test',
- 'user' => 'promsystem',
- 'pass' => 'PrmSystem212'
- ],
- 'dev' => [
- 'host' => 'dmatter.net',
- 'db' => 'promsystem2',
- 'user' => 'promsystem',
- 'pass' => 'PrmSystem212'
- ]
- ];
- /**
- * @return false|\mysqli
- */
- public static function getLink()
- {
- $dbConfig = self::$config['dev'];
- $link = mysqli_connect($dbConfig['host'], $dbConfig['user'], $dbConfig['pass']);
- mysqli_select_db($link, $dbConfig['db']);
- mysqli_query($link,"SET NAMES utf8");
- mysqli_query($link,"SET time_zone = '+03:00';");
- return $link;
- }
- public static function getDevConfig()
- {
- return self::getConfig();
- }
- public static function getTestConfig()
- {
- return self::getConfig('test');
- }
- /**
- * Возвращает настройки подключения к БД на dmatter.net
- *
- * @return string[]
- */
- protected static function getConfig(string $env = 'dev')
- {
- return [
- self::$config[$env]['host'],
- self::$config[$env]['db'],
- self::$config[$env]['user'],
- self::$config[$env]['pass'],
- ];
- }
- }
|