I have a parent table and a child table. In the child table is a foreign key pointing to the parent table. On the "ondelete" is set to "restrict".
This is correct, but despite doctrine is not able to delete the row, it does not raise an exception when I flush entity. it's possible to intercept this behavior?
<?php
use Doctrine\ORM\Mapping as ORM;
/**
* Test1
*
* @ORM\Table(name="test1")
* @ORM\Entity
*/
class Test1
{
/**
* @var integer
*
* @ORM\Column(name="id", type="bigint", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255, nullable=false)
*/
private $title;
}
use Doctrine\ORM\Mapping as ORM;
/**
* Test2
*
* @ORM\Table(name="test2", indexes={@ORM\Index(name="test2_ibfk_1", columns={"idtxt1"})})
* @ORM\Entity
*/
class Test2
{
/**
* @var integer
*
* @ORM\Column(name="idt2", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $idt2;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=100, nullable=true)
*/
private $title;
/**
* @var \Test1
*
* @ORM\ManyToOne(targetEntity="Test1")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="idtxt1", referencedColumnName="id")
* })
*/
private $idtxt1;
}
CREATE TABLE `test1` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
CREATE TABLE `test2` (
`idt2` int(11) NOT NULL AUTO_INCREMENT,
`idtxt1` bigint(20) NOT NULL,
`title` varchar(100) DEFAULT NULL,
PRIMARY KEY (`idt2`),
KEY `idtxt1` (`idtxt1`),
CONSTRAINT `test2_ibfk_2` FOREIGN KEY (`idtxt1`) REFERENCES `test1` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8