我需要删除具有以下关系的两个对象之间的关联
Devis实体:
class Devis
{
/**
* @var \stdClass
*
* @ORM\ManyToOne(targetEntity="DevisBundle\Entity\Client", inversedBy="devis", cascade={"persist"})
* @ORM\JoinColumn(nullable=false, nullable=true)
*/
private $client;
/**
* Set client
*
* @param \DevisBundle\Entity\Client $client
* @return Devis
*/
public function setClient(\DevisBundle\Entity\Client $client)
{
$this->client = $client;
return $this;
}
客户实体:
class Client
{
/**
* @var \stdClass
*
* @ORM\OneToMany(targetEntity="DevisBundle\Entity\Devis", mappedBy="client", cascade={"remove"})
*/
private $devis;
中删除文档
$devis = $em->getRepository('DevisBundle:Devis')->findOneById($devisId);
$client = $em->getRepository('DevisBundle:Client')->findOneById($devis->getClient());
$client->getDevis()->removeElement($devis);
$devis->setClient(null);
//$em->persist($devis);
$em->flush();
dump($devis);
但我有这个错误:
捕获致命错误:传递给DevisBundle \ Entity \ Devis :: setClient()的参数1必须是DevisBundle \ Entity \ Client的实例,null给定,调用....
答案 0 :(得分:3)
像这样更改你的方法:
var table = $('#example').DataTable();
$('#example tbody').on( 'click', 'tr', function () {
var data = table.row( this ).data();
data.digit.current_value++;
table
.row( this )
.data( data )
.draw(false);
} );
这也是使用命令doctrine:generate:entities。
生成的方式