database.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // 数据库配置
  3. $config = [
  4. // 服务器地址
  5. 'host' => '127.0.0.1',
  6. // 数据库名
  7. 'database' => 'yoshop_pro2',
  8. // 用户名
  9. 'username' => 'root',
  10. // 密码
  11. 'password' => 'root',
  12. // 端口号
  13. 'hostport' => '3306',
  14. // 数据库编码默认采用utf8
  15. 'charset' => 'utf8',
  16. ];
  17. return [
  18. // 默认使用的数据库连接配置
  19. 'default' => env('database.driver', 'mysql'),
  20. // 自定义时间查询规则
  21. 'time_query_rule' => [],
  22. // 自动写入时间戳字段
  23. // true为自动识别类型 false关闭
  24. // 字符串则明确指定时间字段类型 支持 int timestamp datetime date
  25. 'auto_timestamp' => true,
  26. // 时间字段取出后的默认时间格式
  27. 'datetime_format' => 'Y-m-d H:i:s',
  28. // 数据库连接配置信息
  29. 'connections' => [
  30. 'mysql' => [
  31. // 数据库类型
  32. 'type' => env('database.type', 'mysql'),
  33. // 服务器地址
  34. 'hostname' => env('database.hostname', $config['host']),
  35. // 数据库名
  36. 'database' => env('database.database', $config['database']),
  37. // 用户名
  38. 'username' => env('database.username', $config['username']),
  39. // 密码
  40. 'password' => env('database.password', $config['password']),
  41. // 端口
  42. 'hostport' => env('database.hostport', $config['hostport']),
  43. // 数据库连接参数
  44. 'params' => [],
  45. // 数据库编码默认采用utf8
  46. 'charset' => env('database.charset', 'utf8'),
  47. // 数据库表前缀
  48. 'prefix' => env('database.prefix', 'yoshop_'),
  49. // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
  50. 'deploy' => 0,
  51. // 数据库读写是否分离 主从式有效
  52. 'rw_separate' => false,
  53. // 读写分离后 主服务器数量
  54. 'master_num' => 1,
  55. // 指定从服务器序号
  56. 'slave_no' => '',
  57. // 是否严格检查字段是否存在
  58. 'fields_strict' => true,
  59. // 是否需要断线重连
  60. 'break_reconnect' => false,
  61. // 监听SQL
  62. 'trigger_sql' => env('app_debug', true),
  63. // 开启字段缓存
  64. 'fields_cache' => false,
  65. // 字段缓存路径
  66. 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
  67. ],
  68. // 更多的数据库配置信息
  69. ],
  70. ];