How to re-save the entity as another row in Doctrine 2

后端 未结 3 1858
眼角桃花
眼角桃花 2020-11-28 04:55

Let\'s say I have entity $e. Is there any generic way to store it as another row, which would have the same entity data but another primary key?

Why I n

3条回答
  •  春和景丽
    2020-11-28 05:26

    I just do:

    /**
     * __clone
     *
     * @return void
     */
    public function __clone()
    {
        $this->id = null;
    }
    

    More details here https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/cookbook/implementing-wakeup-or-clone.html

提交回复
热议问题