database.php 6.3 KB

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