Doctrine preUpdate Listener未在数据库中设置字段值

时间:2012-07-25 03:11:50

标签: php symfony doctrine-orm

我有这段代码

public function preUpdate(PreUpdateEventArgs $args)
{
    $entity = $args->getEntity();
    $em = $args->getEntityManager();
    $uow = $em->getUnitOfWork();
    $args->isActive = false;

    $meta = $em->getClassMetadata(get_class($entity));
    $uow->recomputeSingleEntityChangeSet($meta, $entity);
}

我尝试了很多次,但没有更新字段。

1 个答案:

答案 0 :(得分:2)

应为$entity->isActive = false;  而不是$args->isActive = false;