database.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. // 数据库配置
  3. $config = [
  4. // 服务器地址
  5. 'host' => env('HOSTNAME','192.168.111.17'),
  6. // 数据库名
  7. 'database' => env('DATABASE','chef_ysc_server'),
  8. // 用户名
  9. 'username' => env('USERNAME','root'),
  10. // 密码
  11. 'password' => env('PASSWORD','123'),
  12. // 端口号
  13. 'hostport' => env('HOSTPORT','3306'),
  14. // 数据库编码默认采用utf8
  15. 'charset' => env('CHARSET','utf8'),
  16. ];
  17. $config_chef = [
  18. // 服务器地址
  19. 'host' => env('CHEF_HOSTNAME','192.168.111.17'),
  20. // 数据库名
  21. 'database' => env('CHEF_DATABASE','chef_ysc_server'),
  22. // 用户名
  23. 'username' => env('CHEF_USERNAME','root'),
  24. // 密码
  25. 'password' => env('CHEF_PASSWORD','123'),
  26. // 端口号
  27. 'hostport' => env('CHEF_HOSTPORT','3306'),
  28. // 数据库编码默认采用utf8
  29. 'charset' => 'utf8',
  30. ];
  31. return [
  32. // 默认使用的数据库连接配置
  33. 'default' => env('database.driver', 'mysql'),
  34. // 自定义时间查询规则
  35. 'time_query_rule' => [],
  36. // 自动写入时间戳字段
  37. // true为自动识别类型 false关闭
  38. // 字符串则明确指定时间字段类型 支持 int timestamp datetime date
  39. 'auto_timestamp' => true,
  40. // 时间字段取出后的默认时间格式
  41. 'datetime_format' => 'Y-m-d H:i:s',
  42. // 数据库连接配置信息
  43. 'connections' => [
  44. 'mysql' => [
  45. // 数据库类型
  46. 'type' => env('database.type', 'mysql'),
  47. // 服务器地址
  48. 'hostname' => env('database.hostname', $config['host']),
  49. // 数据库名
  50. 'database' => env('database.database', $config['database']),
  51. // 用户名
  52. 'username' => env('database.username', $config['username']),
  53. // 密码
  54. 'password' => env('database.password', $config['password']),
  55. // 端口
  56. 'hostport' => env('database.hostport', $config['hostport']),
  57. // 数据库连接参数
  58. 'params' => [],
  59. // 数据库编码默认采用utf8
  60. 'charset' => env('database.charset', 'utf8'),
  61. // 数据库表前缀
  62. 'prefix' => env('database.prefix', 'yoshop_'),
  63. // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
  64. 'deploy' => 0,
  65. // 数据库读写是否分离 主从式有效
  66. 'rw_separate' => false,
  67. // 读写分离后 主服务器数量
  68. 'master_num' => 1,
  69. // 指定从服务器序号
  70. 'slave_no' => '',
  71. // 是否严格检查字段是否存在
  72. 'fields_strict' => true,
  73. // 是否需要断线重连
  74. 'break_reconnect' => false,
  75. // 监听SQL
  76. 'trigger_sql' => env('app_debug', true),
  77. // 开启字段缓存
  78. 'fields_cache' => false,
  79. // 字段缓存路径
  80. 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
  81. ],
  82. 'chef' => [
  83. // 数据库类型
  84. 'type' => env('database.type', 'mysql'),
  85. // 服务器地址
  86. 'hostname' => env('database.chef_hostname', $config_chef['host']),
  87. // 数据库名
  88. 'database' => env('database.chef_database', $config_chef['database']),
  89. // 用户名
  90. 'username' => env('database.chef_username', $config_chef['username']),
  91. // 密码
  92. 'password' => env('database.chef_password', $config_chef['password']),
  93. // 端口
  94. 'hostport' => env('database.chef_hostport', $config_chef['hostport']),
  95. // 数据库连接参数
  96. 'params' => [],
  97. // 数据库编码默认采用utf8
  98. 'charset' => env('database.charset', 'utf8'),
  99. // 数据库表前缀
  100. 'prefix' => env('database.chef_prefix', ''),
  101. // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
  102. 'deploy' => 0,
  103. // 数据库读写是否分离 主从式有效
  104. 'rw_separate' => false,
  105. // 读写分离后 主服务器数量
  106. 'master_num' => 1,
  107. // 指定从服务器序号
  108. 'slave_no' => '',
  109. // 是否严格检查字段是否存在
  110. 'fields_strict' => true,
  111. // 是否需要断线重连
  112. 'break_reconnect' => false,
  113. // 监听SQL
  114. 'trigger_sql' => env('app_debug', true),
  115. // 开启字段缓存
  116. 'fields_cache' => false,
  117. // 字段缓存路径
  118. 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
  119. ],
  120. // 更多的数据库配置信息
  121. ],
  122. ];