【发布时间】:2021-02-11 10:44:49
【问题描述】:
我在多个表中有country 的id(主键),我想检查它的值是否存在于另一个引用的表中。
尝试使用以下代码,但我认为这不是正确的方法。谁能给点建议...
public function check($id)
{
$state = State::pluck('country_id');
$country = DB::select("select count(*) from country where ? not in (?)",[$id,$state]);
if($country == 0)
{
//
}
else{
//
}
}
【问题讨论】: