你好StackOverflowers! 我今天的问题是如何使用相关列插入数据。 所以这是我的代码。
$firstEntity->setUserName("login") ->setUserPassword("password") ->setUserEmail("email") $this->em->persist($firstEntity); $this->em->flush(); $secondEntity = new secondEntity(); $secondEntity->setSurname("surname") ->setName("name") ->setCity("city"); $this->em->persist($secondEntity); $this->em->flush();
现在我有一对一的相关列:" first_entity_id"使用" second_entity_id"。以下是我的问题如何在一个链接中执行此操作?喜欢:
$firstEntity->setUserName("login") ->setUserPassword("password") ->setUserEmail("email") ->setSecondDetailsId() ->setSurname("surname") //from second entity ->setName("name") //from second entity ->setCity("city"); //from second entity $this->em->persist($secondEntity); $this->em->flush();
问候