Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ComputeChangeSet():是否应返回所属方集合更改?_Php_Doctrine Orm - Fatal编程技术网

Php ComputeChangeSet():是否应返回所属方集合更改?

Php ComputeChangeSet():是否应返回所属方集合更改?,php,doctrine-orm,Php,Doctrine Orm,请遵循以下示例: /** * @ORM\Table(...) * @ORM\Entity(...) */ class Foo { /** * @ORM\OneToMany(targetEntity="Bar", mappedBy="foo") */ protected $bars; //setters and getters omitted } 在教义2中,应该 $cs = $this->computeChangeSet(

请遵循以下示例:

/**
 * @ORM\Table(...)   
 * @ORM\Entity(...)
 */
class Foo
{
    /**
     * @ORM\OneToMany(targetEntity="Bar", mappedBy="foo")
     */
    protected $bars;

    //setters and getters omitted
}
在教义2中,应该

$cs = $this->computeChangeSet(
    $em->getClassMetadata(get_class($foo)),
    $foo
);
如果更改了
$bar
,返回
['bar']


我这样问是因为,据我所知,doctrine2只考虑拥有方的变化

好问题。也许它仍然在一个变更集中注册变更,但当持久化时,它意识到这些变更不需要被持久化?@Wilt测试它,返回关于拥有方的任何信息。这迫使我在用新的表单值绑定对象之前存储“previous”集合。我当然知道doctrine2 preUpdate()事件