I came into a problem I can't solve for several days now.
I have a groupe table and a statistiquequestion table.
1 statistiquequestion --> several groupes 1 groupe --> several statistiquequestion
I set up a ManyToMany relationship.
Entities :
Groupe :
/**
* Groupe
*
* @ORM\Table(name="groupe")
* @ORM\Entity
*/
class Groupe
{
...
/**
* @ORM\ManyToMany(targetEntity="\PACES\StatistiqueBundle\Entity\StatistiqueQuestion", mappedBy="groupes",
* cascade={"all"})
*/
private $statistiquesquestion;
....
}
StatistiqueQuestion :
/**
* StatistiqueQuestion
*
* @ORM\Table(name="statistiquequestion")
* @ORM\Entity
*/
class StatistiqueQuestion
{
...
/**
* @ORM\ManyToMany(targetEntity="\PACES\UserBundle\Entity\Groupe",inversedBy="statistiquesquestion" , cascade={"persist"})
* @ORM\JoinColumn(name="groupe_id", referencedColumnName="id")
*/
private $groupes;
....
}
When I try to find a StatistiqueQuestion object, I have this error :
SQLSTATE[42S22]: Column not found: 1054 Unrecognized field 'statistiquequestion_groupe.groupe_id' in where clause
Here's my code to get the object :
$statsQuestion[]=$em->getRepository( StatistiqueQuestion::class )->findOneBy( [ 'question' => $colle,
'groupes' => $groupes
] );
When I dump $groupes, I get an array of objects as intended.