有沒有辦法在實體管理器(doctrine)中手動指定symfony2中的事務,或者是在單個事務中完成我在下面做的兩個事情的一種自然方式?Transactions和symfony2實體管理器
// creating screen object...
//Creating user object...
//flush the screen into database in order to get the Id to relate the server (user) to
$em->persist($screen);
$em->flush();
//Get id of just inserted screen and attach that to new server (user)
$tempRecordId = $screen->getId();
$tempEntity = $em->getRepository('BizTVContainerManagementBundle:Container')->find($tempRecordId);
$entity->setScreen($tempEntity);
//Flush the user also into database
$em->persist($entity);
$em->flush();
見我必須刷新我的第一個實體,以獲取它的ID了,所以我可以與我的第二個實體給我的第一...
不知道這是那麼簡單!我想我會讓它變得比它需要的更復雜! – 2012-08-17 19:56:09