Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php获取数据库中同名但创建者不同的数据?_Php - Fatal编程技术网

如何使用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)->

我正在尝试使用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)->groupBy('name')->get();
  }

但它只显示具有相同
帐户名的数据
,即使它们有不同的创建者
创建人
我想删除这个问题,因为我自己解决了这个问题,但我只发布我的解决方案。有人可能需要它:

$group = \App\Group::where('account_name', '=', $grp->account_name)->where('created_by', 'LIKE', $grp->created_by)->groupBy('name')->get();