如何使用php获取数据库中同名但创建者不同的数据?
我正在尝试使用php检索表中的数据,条件是如何使用php获取数据库中同名但创建者不同的数据?,php,Php,我正在尝试使用php检索表中的数据,条件是如果相同的创建者和相同的帐户名,则打印。我使用的代码是: $groups = \App\Group::where('created_by', '=', $grp->created_by)->get(); if($groups->count() > 0){ $group = \App\Group::where('account_name', 'LIKE', $groups[0]->account_name)->
如果相同的创建者和相同的帐户名,则打印。我使用的代码是:
$groups = \App\Group::where('created_by', '=', $grp->created_by)->get();
if($groups->count() > 0){
$group = \App\Group::where('account_name', 'LIKE', $groups[0]->account_name)->groupBy('name')->get();
}
但它只显示具有相同帐户名的数据
,即使它们有不同的创建者创建人
我想删除这个问题,因为我自己解决了这个问题,但我只发布我的解决方案。有人可能需要它:
$group = \App\Group::where('account_name', '=', $grp->account_name)->where('created_by', 'LIKE', $grp->created_by)->groupBy('name')->get();