Get the last insert id with doctrine 2?

后端 未结 7 2283
礼貌的吻别
礼貌的吻别 2020-12-08 03:26

How can I get the last insert id with doctrine 2 ORM? I didn\'t find this in the documentation of doctrine, is this even possible?

相关标签:
7条回答
  • 2020-12-08 04:32

    I had to use this after the flush to get the last insert id:

    $em->persist($user);
    $em->flush();
    $user->getId();
    
    0 讨论(0)
提交回复
热议问题