Laravel, uses union to connect multiple queries, and an error will be reported when a query is empty. How to solve this problem?

there are three tables of A _

$a=DB::table("A")->where("some condition");
$b=DB::table("B")->where("some condition");
$c=DB::table("C")->where("some condition")->union($a)->union($b);

if the result set of $an or $b is empty, an error will be reported.
the solution now is to judge $a-> get () and $b-> get (), respectively, and union them if they are not empty, but there are actually a large number of tables, and each judgment is too inelegant.

so is there any elegant solution?

Mar.02,2021

http://www.it1352.com/671764.

I hope it will be helpful to you

yard farmhouse

Menu