我的代码中有一个hasone关系,
public function getDevice(){
return $this->hasOne(UserDevice::className(),['user_id' => 'id'])->where(['is_latest'=>true]);
}
在我的查询中,我尝试获取用户详细信息。
$query = User::find();
$query->joinWith('device')->all();
如果我使用getDevice时没有where条件,我将获得所有用户。但是如果我在getDevice中添加where条件,我将获得具有设备详细信息的用户。是否有任何方法可以列出具有检查的所有用户。也就是说,我需要列出所有用户,这些用户在设备表中是否具有详细信息
1条答案
按热度按时间zbsbpyhn1#
我已经在我的关系中使用了这个,它起作用了。