【发布时间】:2019-02-08 18:01:48
【问题描述】:
我的表格字段:
id name
1 cat
2 dog
3 frog
我的餐桌产品组
id name
1 animals
2 food
3 colors
我的表字段_productgroup
fields_1 productgroup_1
1 1
2 1
3 2
我现在要做的是删除frog 与colors 的关系。
我的控制器:
public function remove($entity, $id, $relation, $relation_id, Request $request)
{
$obj = $this->getDoctrine()->getRepository(fields::class)->findOneBy(['id' => $id]);
$entity_id = $obj->getId();
$enity_reference = $entityManager->getReference(fields::class, $entity_id);
$relation_reference = $entityManager->getReference(productgroup::class, $relation_id);
$func = 'removeProductgroup';
$enity_reference->$func($relation_reference);
$entityManager->persist($enity_reference);
$entityManager->persist($relation_reference);
$entityManager->flush();
$response = new Response();
$response->send();
return $response;
}
这是我的字段实体中的函数:
public function removeProductgroup(Productgroup $productgroup)
{
$this->productgroup->removeElement($productgroup)
return $this;
}
但我收到错误消息:
语法错误,意外'return' (T_RETURN)
【问题讨论】:
标签: php symfony doctrine entity symfony4