I got 3 entities:
1st:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* ProactiveSubject
*
* @ORM\Table(name="ProactiveSubject")
* @ORM\Entity
*/
class ProactiveSubject
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\ManyToMany(targetEntity="ProactiveCheck", inversedBy="p_subjects")
* @ORM\JoinTable(name="subject_check_operator")
*/
private $checks;
public function __construct() {
$this->checks = new \Doctrine\Common\Collections\ArrayCollection();
}
}
2nd:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* ProactiveCheck
*
* @ORM\Table(name="ProactiveCheck")
* @ORM\Entity
*/
class ProactiveCheck
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\ManyToMany(targetEntity="ProactiveSubject", mappedBy="ProactiveChecks")
*/
private $p_subjects;
public function __construct() {
$this->p_subjects = new \Doctrine\Common\Collections\ArrayCollection();
}
}
and 3rd:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* ProactiveOperator
*
* @ORM\Table(name="ProactiveOperator")
* @ORM\Entity
*/
class ProactiveOperator
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\ManyToMany(targetEntity="ProactiveSubject", inversedBy="p_subjects")
*
*/
private $p_operator;
public function __construct() {
$this->p_operator = new \Doctrine\Common\Collections\ArrayCollection();
}
}
In short, 1 subject may have many checks, and these checks may have many operators, so it should look like that:
subject1 ==> check EQUALITY ==> operator =
subject1 ==> check GREATER ==> operator >
subject2 ==> check AMOUNT ==> operator = or operator > or operator < etc... depending on user input
I need to make something like a a many_tomany_tomany connection in my db so 3 entities should be connected through 1 join table. The problem is that when I run doctrine:schema:update --force
, it connects only 2 entities (operator
and subject
), but does not connect a Check
entity. Any Ideas how to fix that and make a table subject_check_operator
with these entities? Any ideas would be welcome. Thank you.