版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_39967349/article/details/84851783
public function selectdb(){
$tables = DB::select('SHOW TABLES');
$object = json_decode( json_encode( $tables),true);
$names = array();
$queries = collect();
foreach($object as $k => $v){
if(strpos($v['Tables_in_shop'],'sp_ad2018') !==false){
$names[] = $v['Tables_in_shop'];
}
}
$query = DB::table('sp_ad')->where('id',1);
$str='';
foreach($names as $k => $v){
if($k==0){
$str = DB::table($v)->where('id',1);
}else{
$a = DB::table($v)->where('id',1);
$str->union($a);
}
}
$p=$str->get();
return json_encode($p);
}