读取对象持久存在,但尚未用学说刷新 [英] read objects persisted but not yet flushed with doctrine
问题描述
我是 symfony2 和学说的新手.这是我看到的问题.我不能使用:
I'm new to symfony2 and doctrine. here is the problem as I see it. i cannot use :
$repository = $this->getDoctrine()->getRepository('entity');
$my_object = $repository->findOneBy($index);
在一个持久化的对象上,但尚未刷新!!我认为 getRepository 从数据库读取,因此它不会找到未刷新的对象.
on an object that is persisted, BUT NOT FLUSHED YET !! i think getRepository read from DB, so it will not find a not-flushed object.
我的问题:如何在我刷新整个批次之前读取那些持久化的对象(我认为它们在教义会话"中的某个地方)以重新使用它们?
my question: how to read those objects that are persisted (i think they are somewhere in a "doctrine session") to re-use them before i do flush my entire batch ?
每个配置文件都有 256 个物理羽状物.
every profile has 256 physical plumes.
每个配置文件都有 1 个分配给它的 plumeOptions
记录.
every profile has 1 plumeOptions
record assigned to it.
在plumeOptions
中,我有一个cartridgeplume,它是PhysicalPlume
的FK.
In plumeOptions
, I have a cartridgeplume which is a FK for PhysicalPlume
.
每个羽流都由 ID
(自动生成)和 INDEX
(用户生成)标识.
every plume is identified by ID
(auto-generated) and an INDEX
(user-generated).
规则:我说配置文件 1 与 physical_plume_index
编号 3(=index)相连.
rule: I say profile 1 has physical_plume_index
number 3 (=index) connected to it.
现在,我想将一个配置文件及其所有相关数据复制到另一个配置文件中.
now, I want to copy a profile with all its related data to another profile.
新配置文件已创建.新的 256 个羽流是从旧的配置文件中创建和复制的.
new profile is created. New 256 plumes are created and copied from older profile.
我想将新配置文件链接到新的羽流指数 3.
在这里查看:http://pastebin.com/WFa8vkt1
推荐答案
我想你可能想看看这个功能:
I think you might want to have a look at this function:
$entityManager->getUnitOfWork()->getScheduledEntityInsertions()
返回一个持久化的实体对象列表.
Gives you back a list of entity objects which are persisting yet.
嗯,我并没有很好地阅读您的问题,通过上面的内容,您将检索完整列表(作为数组),但您无法像使用 getRepository 那样查询它.我会试着为你找到一些东西..
Hmm, I didn't really read your question well, with the above you will retrieve a full list (as an array) but you cannot query it like with getRepository. I will try found something for u..
这篇关于读取对象持久存在,但尚未用学说刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!