database.php 3.9 KB

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