交响乐6.4
这是我的架构: 命题:PK(测试 ID、RUBRIQUEID、问题 ID、命题 ID)
我正在尝试使用 Symfony 的 EntityManagerInterface 删除一个命题,但删除了两个命题:
$proposition = $manager->getRepository(Proposition::class)->findOneBy(['TESTID' => $testid, 'RUBRIQUEID' => $rubriqueid , 'QUESTIONID' => $questionid,'PROPOSITIONID' => $propositionid]);
$manager->remove($proposition);
$manager->flush();
命题 (TESTID = 1 RUBRIQUEID = 1 QUESTIONID = 1 PROPOSITIONID = 1) 以及命题 (TESTID = 1 RUBRIQUEID = 1 QUESTIONID 2 = PROPOSITIONID = 1)。
这些命题可能会被删除,因为它们共享相同的命题 ID 但具有不同的 TESTID。当我使用 dd() 进行调试时,我只看到第一个命题。我不确定为什么这两个提议都被删除了
感谢您的帮助!
这就是我的课程:
课堂测试
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(name:"TESTID")]
#[ORM\OneToMany(targetEntity:Rubrique::class, mappedBy: 'TESTID')]
private ?int $TESTID = null;
红布里克级:
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(name:"RUBRIQUEID")]
#[ORM\OneToMany(targetEntity: Question::class, mappedBy: 'RUBRIQUEID')]
private ?int $RUBRIQUEID = null;
#[ORM\ManyToOne(targetEntity: Test::class, inversedBy: 'TESTID')]
#[ORM\JoinColumn(name: "TESTID", referencedColumnName: "TESTID")]
private ?Test $TESTID;
课堂问题:
#[ORM\Id]
#[ORM\Column(name:"QUESTIONID")]
private ?int $QUESTIONID = null;
#[ORM\ManyToOne(targetEntity: Test::class, inversedBy: 'TESTID')]
#[ORM\JoinColumn(name: "TESTID", referencedColumnName: "TESTID")]
private ?Test $TESTID;
#[ORM\ManyToOne(targetEntity: Rubrique::class, inversedBy: 'RUBRIQUEID')]
#[ORM\JoinColumn(name: "RUBRIQUEID", referencedColumnName: "RUBRIQUEID")]
private ?Rubrique $RUBRIQUEID;
#[ORM\OneToMany(mappedBy: 'QUESTIONID', targetEntity: Proposition::class, cascade:["persist","remove"])]
#[ORM\OrderBy(['PROPOSITIONID' => 'ASC'])]
private Collection $Propositions;
课堂命题
#[ORM\Id]
#[ORM\Column]
private ?int $PROPOSITIONID = null;
#[ORM\ManyToOne(targetEntity: Test::class, inversedBy: 'TESTID')]
#[ORM\JoinColumn(name: "TESTID", referencedColumnName: "TESTID")]
private ?Test $TESTID;
#[ORM\ManyToOne(targetEntity: Rubrique::class, inversedBy: 'RUBRIQUEID')]
#[ORM\JoinColumn(name: "RUBRIQUEID", referencedColumnName: "RUBRIQUEID")]
private ?Rubrique $RUBRIQUEID;
#[ORM\ManyToOne(targetEntity: Question::class, inversedBy: 'Propositions')]
#[ORM\JoinColumn(name: "QUESTIONID", referencedColumnName: "QUESTIONID", onDelete:"CASCADE")]
private ?Question $QUESTIONID;