Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.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
Symfony 更新实体或其关系时的跟踪_Symfony_Doctrine_Timestamp - Fatal编程技术网

Symfony 更新实体或其关系时的跟踪

Symfony 更新实体或其关系时的跟踪,symfony,doctrine,timestamp,Symfony,Doctrine,Timestamp,我正在使用Symfony 2.4和ORM。我有一个父实体,即财产,它有许多子关系,包括: propertyVideos(OneToMany) 房地产照片(OneToMany) 物业定位(OneToOne) 在属性实体的LastUpdate字段中,我需要存储属性实体或其任何相关实体上次更新的日期和时间 在Symfony/Doctrine中有没有一种简单的方法可以做到这一点?最简单的方法是使用gedmo/Doctrine扩展或(对于Symfony)stof/Doctrine扩展包,然后您可以使用

我正在使用Symfony 2.4和ORM。我有一个父实体,即财产,它有许多子关系,包括:

  • propertyVideos(OneToMany)
  • 房地产照片(OneToMany)
  • 物业定位(OneToOne)
在属性实体的LastUpdate字段中,我需要存储属性实体或其任何相关实体上次更新的日期和时间


在Symfony/Doctrine中有没有一种简单的方法可以做到这一点?

最简单的方法是使用
gedmo/Doctrine扩展
或(对于Symfony)
stof/Doctrine扩展包
,然后您可以使用该包执行以下操作

Entity\Article:
    type: entity
    table: articles
    fields:
        created:
            type: date
            gedmo:
                timestampable:
                    on: create // $this create
        updated:
            type: datetime
            gedmo:
                timestampable:
                    on: update // $this update
        published:
            type: datetime
            gedmo:
                timestmpable:
                    on: change
                    field: type.title
                    value: Published
                              // $this->type->title changed to "Published"
        blah:
            type: datetime
            gedmo:
                timestampable:
                    on: change
                    field: type.somethingelse
                              // $this->type.somethingelse is changed
    manyToOne:
        type:
            targetEntity: Entity\Type
            inversedBy: articles

谢谢你的回复,但是追踪一下一对夫妻关系的变化呢?这将如何处理?@user3009816我在寻找同样的东西,但我们必须使用条令侦听器或生命周期事件手动处理它,正如bundle的作者所说