简体   繁体   English

如何在Propel(也是Doctrine)-Symfony 1.4中强制重新关联结果?

[英]How to force refetch of association results in Propel (also Doctrine) - Symfony 1.4?

I have 2 entities: Parent with one-to-many relationship with Child. 我有2个实体:父母与孩子具有一对多关系。

I use the $parent->getChilds() automatically generated method by Propel to fetch all the childs. 我使用Propel自动生成的$parent->getChilds()方法来获取所有子项。

Afterwards I manually add (or remove) some new childs in different method: 之后,我以不同的方法手动添加(或删除)一些新的子项:

$child = new Child();
$child->setParentId($parent->getId());
$child->save();

Now if I recall the getChilds method I get the same original childs (and also no extra query to the database). 现在,如果我回想起getChilds方法,我将得到相同的原始子项(并且也无需对数据库进行任何额外查询)。

I understand that this is better behaviour and more efficient, but is there a way to force to refetch? 我知道这是更好的行为,更有效,但是有没有办法强制重新引用呢?

Thanks. 谢谢。

$parent->reload(true)

应该推动

从未使用过它,但是您可能正在寻找Doctrine_Record#refresh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM