I am not sure if this is even possible but i have this scenario with my Laravel install.
I am running 3 live databases (will be more over time), I have one laravel installation, and what I want to do is merge all the data using the different connections and run 1 query to get all the data with all relationships etc.... basically want to use eloquent. All the database are the same in terms of table designs, index, keys etc, but I am not sure if its even possible!
I want to be able to write one query for example: Users::all();
which uses all the connections at once.
The only way in which i know it will work would be doing is this way.
'connection1' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'connection2' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
DB::connection('connection1')->table('table_here')->get();
Anyone know if this is even possible.