database.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. 'mysqlT9' => [
  91. 'driver' => 'mysql',
  92. 'url' => env('DATABASE_URL'),
  93. 'host' => '121.37.161.210',
  94. 'port' => env('DB_PORT', '3306'),
  95. 'database' => 'tj',
  96. 'username' => 'tj',
  97. 'password' => 'tj1@Q3wa$ESZ',
  98. 'unix_socket' => env('DB_SOCKET', ''),
  99. 'charset' => 'utf8mb4',
  100. 'collation' => 'utf8mb4_unicode_ci',
  101. 'prefix' => '',
  102. 'prefix_indexes' => true,
  103. 'strict' => false,
  104. 'engine' => null,
  105. 'options' => extension_loaded('pdo_mysql') ? array_filter([
  106. PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
  107. ]) : [],
  108. ],
  109. //sqlserver t9 用友数据库
  110. 'sqlsrvs' => [
  111. 'driver' => 'sqlsrv',
  112. 'host' => '',
  113. 'port' => '',
  114. 'database' => '',
  115. 'username' => '',
  116. 'password' => '',
  117. ],
  118. 'pgsql' => [
  119. 'driver' => 'pgsql',
  120. 'url' => env('DATABASE_URL'),
  121. 'host' => env('DB_HOST', '127.0.0.1'),
  122. 'port' => env('DB_PORT', '5432'),
  123. 'database' => env('DB_DATABASE', 'forge'),
  124. 'username' => env('DB_USERNAME', 'forge'),
  125. 'password' => env('DB_PASSWORD', ''),
  126. 'charset' => 'utf8',
  127. 'prefix' => '',
  128. 'prefix_indexes' => true,
  129. 'schema' => 'public',
  130. 'sslmode' => 'prefer',
  131. ],
  132. 'sqlsrv' => [
  133. 'driver' => 'sqlsrv',
  134. 'url' => env('DATABASE_URL'),
  135. 'host' => env('DB_HOST', 'localhost'),
  136. 'port' => env('DB_PORT', '1433'),
  137. 'database' => env('DB_DATABASE', 'forge'),
  138. 'username' => env('DB_USERNAME', 'forge'),
  139. 'password' => env('DB_PASSWORD', ''),
  140. 'charset' => 'utf8',
  141. 'prefix' => '',
  142. 'prefix_indexes' => true,
  143. ],
  144. ],
  145. /*
  146. |--------------------------------------------------------------------------
  147. | Migration Repository Table
  148. |--------------------------------------------------------------------------
  149. |
  150. | This table keeps track of all the migrations that have already run for
  151. | your application. Using this information, we can determine which of
  152. | the migrations on disk haven't actually been run in the database.
  153. |
  154. */
  155. 'migrations' => 'migrations',
  156. /*
  157. |--------------------------------------------------------------------------
  158. | Redis Databases
  159. |--------------------------------------------------------------------------
  160. |
  161. | Redis is an open source, fast, and advanced key-value store that also
  162. | provides a richer body of commands than a typical key-value system
  163. | such as APC or Memcached. Laravel makes it easy to dig right in.
  164. |
  165. */
  166. 'redis' => [
  167. 'client' => env('REDIS_CLIENT', 'phpredis'),
  168. 'options' => [
  169. 'cluster' => env('REDIS_CLUSTER', 'redis'),
  170. 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
  171. ],
  172. 'default' => [
  173. 'url' => env('REDIS_URL'),
  174. 'host' => env('REDIS_HOST', '127.0.0.1'),
  175. 'password' => env('REDIS_PASSWORD', null),
  176. 'port' => env('REDIS_PORT', '6379'),
  177. 'database' => env('REDIS_DB', '0'),
  178. ],
  179. 'cache' => [
  180. 'url' => env('REDIS_URL'),
  181. 'host' => env('REDIS_HOST', '127.0.0.1'),
  182. 'password' => env('REDIS_PASSWORD', null),
  183. 'port' => env('REDIS_PORT', '6379'),
  184. 'database' => env('REDIS_CACHE_DB', '1'),
  185. ],
  186. ],
  187. ];