@deron
To use multiple DB2 databases in Laravel, you can follow these steps:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
'connections' => [ 'default' => [ 'driver' => 'db2', 'database' => env('DB_DATABASE', 'homestead'), 'host' => env('DB_HOST', '127.0.0.1'), 'username' => env('DB_USERNAME', 'homestead'), 'password' => env('DB_PASSWORD', 'secret'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'schema' => 'YOUR_SCHEMA', 'commands' => [], ], 'secondary' => [ 'driver' => 'db2', 'database' => env('DB_SECONDARY_DATABASE', 'secondary'), 'host' => env('DB_SECONDARY_HOST', '127.0.0.1'), 'username' => env('DB_SECONDARY_USERNAME', 'homestead'), 'password' => env('DB_SECONDARY_PASSWORD', 'secret'), 'charset' => 'utf8', 'prefix' => '', 'schema' => 'SECONDARY_SCHEMA_NAME', ], ], |
1 2 3 4 5 6 7 8 9 10 11 |
DB_CONNECTION=default DB_HOST=127.0.0.1 DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret DB_SECONDARY_CONNECTION=secondary DB_SECONDARY_HOST=127.0.0.1 DB_SECONDARY_DATABASE=secondary DB_SECONDARY_USERNAME=homestead DB_SECONDARY_PASSWORD=secret |
1
|
$data = DB::connection('secondary')->table('table_name')->get(); |
By following these steps, you can easily use multiple DB2 databases in your Laravel application.