Laravel DB Fasade for Join query with a union()



当我设置了一个".env"来使用两个数据库时,还编写了如下代码来使用它。

但是where()方法不正确使用它。

你能告诉我更详细的用法来使用where()方法和解释或告诉一些学习链接吗?

谢谢。

$master = DB::connection('master_db')->table('customer_master')
->where(['name', '=', 'string'],
['tel', '=', 'integer'],
['address','=', 'string']);
$slave = DB::connection('slave_db')->table('customer_slave')
->where(['histories', '=', 'string'])
->union($master)
->get();

像这样编写查询:

$master = DB::connection('master_db')->table('customer_master')
->where([
'name' => 'string',
'tel' => 'integer',
'address' => 'string'
]);
$slave = DB::connection('slave_db')->table('customer_slave')
->where('histories', 'string')
->union($master)
->get();

在这里,数组语法已针对$master进行了调整,where()针对$slave进行了调整。=比较是默认设置,因此无需在此处指定。

最新更新