database.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. // 线上配置 ip 10.46.2.149 端口 3306 用户名 pacs 密码 Zskk@2019~!@# 数据库名 pacsonline
  12. $xml = ROOT_PATH.'/public/data.xml';
  13. $xml_object = simplexml_load_file($xml);
  14. $xml_json = json_encode($xml_object);//转换为json数据
  15. $xml_array = json_decode($xml_json,true);//转换成数组
  16. $hostname = $xml_array['hostname'];
  17. $database = $xml_array['database'];
  18. $username = $xml_array['username'];
  19. $password = $xml_array['password'];
  20. $hostport = $xml_array['hostport'];
  21. return [
  22. // 数据库类型
  23. 'type' => 'think\oracle\W7Connection',
  24. // 服务器地址
  25. 'hostname' => $hostname,
  26. // 数据库名
  27. 'database' => $database,
  28. // 用户名
  29. 'username' => $username,
  30. // 密码
  31. 'password' => $password,
  32. // 端口
  33. 'hostport' => $hostport,
  34. // 连接dsn
  35. 'dsn' => '',
  36. // 数据库连接参数
  37. 'params' => [],
  38. // 数据库编码默认采用utf8
  39. 'charset' => 'utf8',
  40. // 数据库表前缀
  41. 'prefix' => '',
  42. // 数据库调试模式
  43. 'debug' => true,
  44. // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
  45. 'deploy' => 0,
  46. // 数据库读写是否分离 主从式有效
  47. 'rw_separate' => false,
  48. // 读写分离后 主服务器数量
  49. 'master_num' => 1,
  50. // 指定从服务器序号
  51. 'slave_no' => '',
  52. // 自动读取主库数据
  53. 'read_master' => false,
  54. // 是否严格检查字段是否存在
  55. 'fields_strict' => true,
  56. // 数据集返回类型
  57. 'resultset_type' => 'array',
  58. // 自动写入时间戳字段
  59. 'auto_timestamp' => false,
  60. // 时间字段取出后的默认时间格式
  61. 'datetime_format' => 'Y-m-d H:i:s',
  62. // 是否需要进行SQL性能分析
  63. 'sql_explain' => false,
  64. // Builder类
  65. 'builder' => '',
  66. // Query类
  67. 'query' => '\\think\\db\\Query',
  68. // 是否需要断线重连
  69. 'break_reconnect' => false,
  70. // 断线标识字符串
  71. 'break_match_str' => [],
  72. 'db_config_private' => [
  73. // 数据库类型
  74. 'type' => '\think\oracle\W7Connection',
  75. // 服务器地址
  76. 'hostname' => $hostname,
  77. // 数据库名
  78. 'database' => $database,
  79. // 用户名
  80. 'username' => $username,
  81. // 密码
  82. 'password' => $password,
  83. // 端口
  84. 'hostport' => $hostport,
  85. ],
  86. 'db_config_public' => [
  87. // 数据库类型
  88. 'type' => '\think\oracle\W7Connection',
  89. 'hostname' => $hostname,
  90. // 数据库名
  91. 'database' => $database,
  92. // 用户名
  93. 'username' => $username,
  94. // 密码
  95. 'password' => $password,
  96. // 端口
  97. 'hostport' => $hostport,
  98. ],
  99. ];