I am trying to find all results in the Monthly
table that have an association with a Category
.
I did my research and the following code should theoretically speaking work but somehow is throwing the following Error Notice: Undefined index: joinColumns in...
The tables are joined by a join table and the keys used is category_id
and monthly_id
tried to run the query using category_id
but still doesnt work and throws another error.
When I run orm:validate-schema
it seems all to be working fine. What am I missing?
From the Monthly Entity
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Bnk\Entity\Category", inversedBy="monthly")
* @ORM\JoinTable(name="months_categories",
* joinColumns={
* @ORM\JoinColumn(name="monthly_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="category_id", referencedColumnName="id")
* }
* )
*/
private $category;
What am i missing so that I can find all Monthly
that are associated with a given Category
?
$months = $this->getEntityManager()
->getRepository('Bnk\Entity\Monthly')
->findBy(
array(
"category"=>$category->getId()
)
);