1
class Report extends Eloquent {
protected $connection1 = 'mysql1';
protected $table1 = 'table1';
protected $connection2 = 'mysql2';
protected $table2 = 'table2';
public function getdetails() {
$mysql1_conn = DB::connection('mysql1');
$mysql2_conn = DB::connection('mysql2');
$result = $mysql1_conn->table('table1 as t1')
->{$mysql2_conn->table('table2 as t2')}
->ON('t1.userid' , '=' , 't2.userid')
->select('t1.id','t2.name','t1.number','t2.address')
->get();
return $result;
}
}
単一のクエリに2つのデータベースからデータを取得することができない、文字列に変換することができませんでした私はERRORにクラスを照らし\データベースのオブジェクトクエリー Builderは
「オブジェクトを取得しています\ Query \ Builderを文字列に変換できませんでした。
クエリの構文に間違いはありませんか? または このタイプのようなデータオブジェクトからデータを取得する方法はありません。 – mouli
get()をtoSql()に置き換え、生成されたクエリを見てください –
Illuminate \ Database \ Query \ Builderクラスのオブジェクトを文字列 の行に変換できませんでした ' - > {$ mysql2_conn-> table ( 'table2 as t2')} ' – mouli