0
有一种方法来连接symfony中的findBy操作的两个结果?如果产品是由用户创建的,我试图将用户对象连接到产品阵列。我的代码:从getRepository连接结果symfony
public function indexAction()
{
$products = $this->getDoctrine()
->getRepository('AppBundle:Product')
->findById($this->getUser()->getId());
if ($products[0]->getCreatedByUser() == 1){
$userDetails = $this->getDoctrine()->getRepository('AppBundle:User')
->findOneById($product->getUserId());
//here somehow to concatenate the value from $user to the $products array
}
return $this->json($products, Response::HTTP_OK, [], [
'groups' => ['products']
]);
}
添加样本输入和输出。 – svgrafov
我不认为' - > findOneById($ id)'(除非您以不同的方式实现它,它与' - > find($ id)''相同)做你认为它的作用。 – ccKep
不,不是...... – IleNea