我有一个有类别的学说实体,因此可以为我需要调用的实体设置一个类别
$category = $categoryRepository->find($categoryId);
$entity->addCategory($category);
是否可以在没有存储库的情况下仅使用 ID 来设置它?
最佳答案
是的,您可以使用引用代理:
$entity->addCategory($em->getReference('MyProject\Model\Category', $categoryId))
关于php - 设置实体子实体而不从存储库加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36604896/