database.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. // local
  20. // 'hostname' => 'localhost',
  21. // 'database' => 'db_db',
  22. //// 'database' => 'mlh_db_temp',
  23. // 'username' => 'root',
  24. // 'password' => '123456',
  25. // 'hostport' => '8889',
  26. // // test
  27. 'hostname' => 'localhost',
  28. 'database' => 'db_db',
  29. 'username' => 'db_db',
  30. 'password' => 'bZzTRxrF5NRNAjxp',
  31. 'hostport' => '33067',
  32. // // Online
  33. // 'hostname' =>'110.42.2.205',
  34. // 'database' => 'mlh_db',
  35. // 'username' => 'mlh_db',
  36. // 'password' => 'mPPpdDxTFeaxZmGZ',
  37. // 'hostport' => '33067',
  38. // 数据库连接参数
  39. 'params' => [],
  40. // 数据库编码默认采用utf8
  41. 'charset' => 'utf8',
  42. // 数据库表前缀
  43. 'prefix' => 'db_',
  44. // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
  45. 'deploy' => 0,
  46. // 数据库读写是否分离 主从式有效
  47. 'rw_separate' => false,
  48. // 读写分离后 主服务器数量
  49. 'master_num' => 1,
  50. // 指定从服务器序号
  51. 'slave_no' => '',
  52. // 是否严格检查字段是否存在
  53. 'fields_strict' => true,
  54. // 是否需要断线重连
  55. 'break_reconnect' => true,
  56. // 监听SQL
  57. 'trigger_sql' => true,
  58. // 开启字段缓存
  59. 'fields_cache' => false,
  60. // 字段缓存路径
  61. 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
  62. ],
  63. // 更多的数据库配置信息
  64. ],
  65. ];