databases.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. ];