databases.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. use function Hyperf\Support\env;
  12. return [
  13. 'default' => [
  14. 'driver' => env('DB_DRIVER2', 'mysql'),
  15. 'host' => env('DB_HOST2', 'localhost'),
  16. 'database' => env('DB_DATABASE2', 'hyperf'),
  17. 'port' => env('DB_PORT2', 3306),
  18. 'username' => env('DB_USERNAME2', 'root'),
  19. 'password' => env('DB_PASSWORD2', ''),
  20. 'charset' => env('DB_CHARSET2', 'utf8'),
  21. 'collation' => env('DB_COLLATION2', 'utf8_unicode_ci'),
  22. 'prefix' => env('DB_PREFIX2', ''),
  23. 'pool' => [
  24. 'min_connections' => 1,
  25. 'max_connections' => 10,
  26. 'connect_timeout' => 10.0,
  27. 'wait_timeout' => 3.0,
  28. 'heartbeat' => -1,
  29. 'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
  30. ],
  31. 'variables' => [
  32. 'time_zone' => '+08:00', // 设置MySQL连接的时区
  33. ],
  34. 'commands' => [
  35. 'gen:model' => [
  36. 'path' => 'app/Model',
  37. 'force_casts' => true,
  38. 'inheritance' => 'Model',
  39. ],
  40. ],
  41. ],
  42. 'secondary' => [
  43. 'driver' => env('DB_DRIVER', 'mysql'),
  44. 'host' => env('DB_HOST', 'localhost'),
  45. 'database' => env('DB_DATABASE', 'hyperf'),
  46. 'port' => env('DB_PORT', 3306),
  47. 'username' => env('DB_USERNAME', 'root'),
  48. 'password' => env('DB_PASSWORD', ''),
  49. 'charset' => env('DB_CHARSET', 'utf8'),
  50. 'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
  51. 'prefix' => env('DB_PREFIX', ''),
  52. 'pool' => [
  53. 'min_connections' => 1,
  54. 'max_connections' => 10,
  55. 'connect_timeout' => 10.0,
  56. 'wait_timeout' => 3.0,
  57. 'heartbeat' => -1,
  58. 'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
  59. ],
  60. 'variables' => [
  61. 'time_zone' => '+08:00', // 设置MySQL连接的时区
  62. ],
  63. 'commands' => [
  64. 'gen:model' => [
  65. 'path' => 'app/Model',
  66. 'force_casts' => true,
  67. 'inheritance' => 'Model',
  68. ],
  69. ],
  70. ],
  71. 'global' => [
  72. 'driver' => env('DB_DRIVER3', 'mysql'),
  73. 'host' => env('DB_HOST3', 'localhost'),
  74. 'database' => env('DB_DATABASE3', 'hyperf'),
  75. 'port' => env('DB_PORT3', 3306),
  76. 'username' => env('DB_USERNAME3', 'root'),
  77. 'password' => env('DB_PASSWORD3', ''),
  78. 'charset' => env('DB_CHARSET3', 'utf8'),
  79. 'collation' => env('DB_COLLATION3', 'utf8_unicode_ci'),
  80. 'prefix' => env('DB_PREFIX3', ''),
  81. 'pool' => [
  82. 'min_connections' => 1,
  83. 'max_connections' => 10,
  84. 'connect_timeout' => 10.0,
  85. 'wait_timeout' => 3.0,
  86. 'heartbeat' => -1,
  87. 'max_idle_time' => (float) env('DB_MAX_IDLE_TIME3', 60),
  88. ],
  89. 'variables' => [
  90. 'time_zone' => '+08:00', // 设置MySQL连接的时区
  91. ],
  92. 'commands' => [
  93. 'gen:model' => [
  94. 'path' => 'app/Model',
  95. 'force_casts' => true,
  96. 'inheritance' => 'Model',
  97. ],
  98. ],
  99. ],
  100. ];