php - How to execute Join queries between multiple Databases that are on different server with Laravel Eloquent? -


this how handle multiple db connections laravel, php framework not python (for whom thinks duplicate post)

<?php return array(      'default' => 'mysql',      'connections' => array(          # our primary database connection         'mysql' => array(             'driver'    => 'mysql',             'host'      => 'host1',             'database'  => 'database1',             'username'  => 'user1',             'password'  => 'pass1'             'charset'   => 'utf8',             'collation' => 'utf8_unicode_ci',             'prefix'    => '',         ),          # our secondary database connection         'mysql2' => array(             'driver'    => 'mysql',             'host'      => 'host2',             'database'  => 'database2',             'username'  => 'user2',             'password'  => 'pass2'             'charset'   => 'utf8',             'collation' => 'utf8_unicode_ci',             'prefix'    => '',         ),     ), ); 

and how connect database.

$user1 = user::on('mysql1')->where(/* ... */)->get() $user2 = user::on('mysql2')->where(/* ... */)->get() 

these select queries. therefore eloquent works flawlessly.

however, when want execute join query operation between these 2 databases, seems not possible.

basically can not using eloquent orm or laravel's query builder.

however, can try use raw expression (https://github.com/laravel/framework/blob/8865d2276be94f0a3497ba3bd26c906ae9e91e1c/src/illuminate/database/query/expression.php#l13 ) or smth this, you'll have write code make model query result.

if use laravel 4 question can help: laravel 4: how run raw sql?


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -