database.php 6.9 KB

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