database.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. use Illuminate\Support\Str;
  3. $mysql = "mysql";// 默认
  4. if (app()->runningInConsole()) {//命令行请求
  5. // $command = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
  6. // if ($command === 'command:insert_cloud') {
  7. // // 有人云数据
  8. // $mysql = "mysql_001";
  9. // }
  10. }else{// HTTP请求
  11. //账套
  12. // $zt = $_SERVER['HTTP_ZT'];
  13. // if($zt === '001') $mysql = "mysql_001";
  14. // if($zt === '002') $mysql = "mysql_002";
  15. }
  16. return [
  17. /*
  18. |--------------------------------------------------------------------------
  19. | Default Database Connection Name
  20. |--------------------------------------------------------------------------
  21. |
  22. | Here you may specify which of the database connections below you wish
  23. | to use as your default connection for all database work. Of course
  24. | you may use many connections at once using the Database library.
  25. |
  26. */
  27. 'default' => env('DB_CONNECTION', 'mysql'),
  28. // 'default' => $mysql,
  29. /*
  30. |--------------------------------------------------------------------------
  31. | Database Connections
  32. |--------------------------------------------------------------------------
  33. |
  34. | Here are each of the database connections setup for your application.
  35. | Of course, examples of configuring each database platform that is
  36. | supported by Laravel is shown below to make development simple.
  37. |
  38. |
  39. | All database work in Laravel is done through the PHP PDO facilities
  40. | so make sure you have the driver for your particular database of
  41. | choice installed on your machine before you begin development.
  42. |
  43. */
  44. 'connections' => [
  45. 'sqlite' => [
  46. 'driver' => 'sqlite',
  47. 'url' => env('DATABASE_URL'),
  48. 'database' => env('DB_DATABASE', database_path('database.sqlite')),
  49. 'prefix' => '',
  50. 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
  51. ],
  52. 'mysql' => [
  53. 'driver' => 'mysql',
  54. 'url' => env('DATABASE_URL'),
  55. 'host' => env('DB_HOST', '127.0.0.1'),
  56. 'port' => env('DB_PORT', '3306'),
  57. 'database' => env('DB_DATABASE', 'forge'),
  58. 'username' => env('DB_USERNAME', 'forge'),
  59. 'password' => env('DB_PASSWORD', ''),
  60. 'unix_socket' => env('DB_SOCKET', ''),
  61. 'charset' => 'utf8mb4',
  62. 'collation' => 'utf8mb4_unicode_ci',
  63. 'prefix' => '',
  64. 'prefix_indexes' => true,
  65. 'strict' => false,
  66. 'engine' => null,
  67. 'options' => extension_loaded('pdo_mysql') ? array_filter([
  68. PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
  69. ]) : [],
  70. ],
  71. 'mysql_001' => [
  72. 'driver' => 'mysql',
  73. 'url' => env('DATABASE_URL'),
  74. 'host' => 'rm-bp11ssr8mdn1xl5pl.mysql.rds.aliyuncs.com',
  75. 'port' => env('DB_PORT', '3306'),
  76. 'database' => 'sys',
  77. 'username' => 'qingyaokeji23',
  78. 'password' => '@9X2p+Nipz2gh_G@',
  79. 'unix_socket' => env('DB_SOCKET', ''),
  80. 'charset' => 'utf8mb4',
  81. 'collation' => 'utf8mb4_unicode_ci',
  82. 'prefix' => '',
  83. 'prefix_indexes' => true,
  84. 'strict' => false,
  85. 'engine' => null,
  86. 'options' => extension_loaded('pdo_mysql') ? array_filter([
  87. \PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
  88. ]) : [],
  89. ],
  90. //sqlserver 用友数据库
  91. 'sqlsrvs' => [
  92. 'driver' => 'sqlsrv',
  93. 'host' => '',
  94. 'port' => '',
  95. 'database' => '',
  96. 'username' => '',
  97. 'password' => '',
  98. ],
  99. 'pgsql' => [
  100. 'driver' => 'pgsql',
  101. 'url' => env('DATABASE_URL'),
  102. 'host' => env('DB_HOST', '127.0.0.1'),
  103. 'port' => env('DB_PORT', '5432'),
  104. 'database' => env('DB_DATABASE', 'forge'),
  105. 'username' => env('DB_USERNAME', 'forge'),
  106. 'password' => env('DB_PASSWORD', ''),
  107. 'charset' => 'utf8',
  108. 'prefix' => '',
  109. 'prefix_indexes' => true,
  110. 'schema' => 'public',
  111. 'sslmode' => 'prefer',
  112. ],
  113. 'sqlsrv' => [
  114. 'driver' => 'sqlsrv',
  115. 'url' => env('DATABASE_URL'),
  116. 'host' => env('DB_HOST', 'localhost'),
  117. 'port' => env('DB_PORT', '1433'),
  118. 'database' => env('DB_DATABASE', 'forge'),
  119. 'username' => env('DB_USERNAME', 'forge'),
  120. 'password' => env('DB_PASSWORD', ''),
  121. 'charset' => 'utf8',
  122. 'prefix' => '',
  123. 'prefix_indexes' => true,
  124. ],
  125. ],
  126. /*
  127. |--------------------------------------------------------------------------
  128. | Migration Repository Table
  129. |--------------------------------------------------------------------------
  130. |
  131. | This table keeps track of all the migrations that have already run for
  132. | your application. Using this information, we can determine which of
  133. | the migrations on disk haven't actually been run in the database.
  134. |
  135. */
  136. 'migrations' => 'migrations',
  137. /*
  138. |--------------------------------------------------------------------------
  139. | Redis Databases
  140. |--------------------------------------------------------------------------
  141. |
  142. | Redis is an open source, fast, and advanced key-value store that also
  143. | provides a richer body of commands than a typical key-value system
  144. | such as APC or Memcached. Laravel makes it easy to dig right in.
  145. |
  146. */
  147. 'redis' => [
  148. 'client' => env('REDIS_CLIENT', 'phpredis'),
  149. 'options' => [
  150. 'cluster' => env('REDIS_CLUSTER', 'redis'),
  151. 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
  152. ],
  153. 'default' => [
  154. 'url' => env('REDIS_URL'),
  155. 'host' => env('REDIS_HOST', '127.0.0.1'),
  156. 'password' => env('REDIS_PASSWORD', null),
  157. 'port' => env('REDIS_PORT', '6379'),
  158. 'database' => env('REDIS_DB', '0'),
  159. ],
  160. 'cache' => [
  161. 'url' => env('REDIS_URL'),
  162. 'host' => env('REDIS_HOST', '127.0.0.1'),
  163. 'password' => env('REDIS_PASSWORD', null),
  164. 'port' => env('REDIS_PORT', '6379'),
  165. 'database' => env('REDIS_CACHE_DB', '1'),
  166. ],
  167. ],
  168. ];