database.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006~2016 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\Env;
  12. \think\Log::init(
  13. [
  14. 'type' => 'File',
  15. 'path' => APP_PATH.'logs/',
  16. 'apart_level' => ['error','sql','info'],
  17. 'time_format' =>'c',
  18. 'file_size' => 1024 * 1024 * 10,
  19. ]
  20. );
  21. return [
  22. // 数据库类型
  23. 'type' => Env::get('database.type', 'mysql'),
  24. // 服务器地址
  25. 'hostname' => Env::get('database.hostname', '127.0.0.1'),
  26. // 数据库名
  27. 'database' => Env::get('database.database', 'promote'),
  28. // 用户名
  29. 'username' => Env::get('database.username', 'root'),
  30. // 密码
  31. 'password' => Env::get('database.password', '123456'),
  32. // 端口
  33. 'hostport' => Env::get('database.hostport', ''),
  34. // 连接dsn
  35. 'dsn' => '',
  36. // 数据库连接参数
  37. 'params' => [],
  38. // 数据库编码默认采用utf8
  39. 'charset' => Env::get('database.charset', 'utf8'),
  40. // 数据库表前缀
  41. 'prefix' => Env::get('database.prefix', ''),
  42. // 数据库调试模式
  43. 'debug' => Env::get('database.debug', true),
  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. 'resultset_type' => 'array',
  56. // 自动写入时间戳字段
  57. 'auto_timestamp' => false,
  58. // 时间字段取出后的默认时间格式,默认为Y-m-d H:i:s
  59. 'datetime_format' => false,
  60. // 是否需要进行SQL性能分析
  61. 'sql_explain' => false,
  62. ];