Doctrine.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\models;
  3. class Doctrine
  4. {
  5. private static $config = [
  6. 'test' => [
  7. 'host' => 'dmatter.net',
  8. 'db' => 'promsystem_test',
  9. 'user' => 'promsystem',
  10. 'pass' => 'PrmSystem212'
  11. ],
  12. 'dev' => [
  13. 'host' => 'dmatter.net',
  14. 'db' => 'promsystem2',
  15. 'user' => 'promsystem',
  16. 'pass' => 'PrmSystem212'
  17. ]
  18. ];
  19. /**
  20. * @return false|\mysqli
  21. */
  22. public static function getLink()
  23. {
  24. $dbConfig = self::$config['dev'];
  25. $link = mysqli_connect($dbConfig['host'], $dbConfig['user'], $dbConfig['pass']);
  26. mysqli_select_db($link, $dbConfig['db']);
  27. mysqli_query($link,"SET NAMES utf8");
  28. mysqli_query($link,"SET time_zone = '+03:00';");
  29. return $link;
  30. }
  31. public static function getDevConfig()
  32. {
  33. return self::getConfig();
  34. }
  35. public static function getTestConfig()
  36. {
  37. return self::getConfig('test');
  38. }
  39. /**
  40. * Возвращает настройки подключения к БД на dmatter.net
  41. *
  42. * @return string[]
  43. */
  44. protected static function getConfig(string $env = 'dev')
  45. {
  46. return [
  47. self::$config[$env]['host'],
  48. self::$config[$env]['db'],
  49. self::$config[$env]['user'],
  50. self::$config[$env]['pass'],
  51. ];
  52. }
  53. }