database.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. use think\facade\Env;
  12. return [
  13. // 默认使用的数据库连接配置
  14. 'default' => Env::get('database.driver', 'mysql'),
  15. // 自定义时间查询规则
  16. 'time_query_rule' => [],
  17. // 自动写入时间戳字段
  18. // true为自动识别类型 false关闭
  19. // 字符串则明确指定时间字段类型 支持 int timestamp datetime date
  20. 'auto_timestamp' => true,
  21. // 时间字段取出后的默认时间格式
  22. 'datetime_format' => 'Y-m-d H:i:s',
  23. // 数据库连接配置信息
  24. 'connections' => [
  25. 'mysql' => [
  26. // 数据库类型
  27. 'type' => Env::get('database.type', 'mysql'),
  28. // 服务器地址
  29. 'hostname' => Env::get('database.hostname', '127.0.0.1'),
  30. // 数据库名
  31. 'database' => Env::get('database.database', 'jinjianghc'),
  32. // 用户名
  33. 'username' => Env::get('database.username', 'root'),
  34. // 密码
  35. 'password' => Env::get('database.password', ''),
  36. // 端口
  37. 'hostport' => Env::get('database.hostport', '3306'),
  38. // 数据库连接参数
  39. 'params' => [],
  40. // 数据库编码默认采用utf8
  41. 'charset' => Env::get('database.charset', 'utf8'),
  42. // 数据库表前缀
  43. 'prefix' => Env::get('database.prefix', 'echo_'),
  44. // 数据库调试模式
  45. 'debug' => Env::get('database.debug', true),
  46. // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
  47. 'deploy' => 0,
  48. // 数据库读写是否分离 主从式有效
  49. 'rw_separate' => false,
  50. // 读写分离后 主服务器数量
  51. 'master_num' => 1,
  52. // 指定从服务器序号
  53. 'slave_no' => '',
  54. // 是否严格检查字段是否存在
  55. 'fields_strict' => true,
  56. // 是否需要断线重连
  57. 'break_reconnect' => false,
  58. // 字段缓存路径
  59. 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
  60. ],
  61. // 更多的数据库配置信息
  62. ],
  63. ];