I'm trying yo make a Doctrine Query by using join queries. I have done the following thing :
public function getCategoriesFromCategorieParentAndConstructeur(): ?Array
{
return $this->createQueryBuilder('c')
->leftJoin('c.categorie_parent_id', 'cp' )
->getQuery()
->getResult();
}
But when I try to display the result the following error appears :
Notice: Undefined index: categories
I have no idea why can you tell me more ?
Here are my 2 Entity : Categorie Entity
/**
* @ORM\Entity(repositoryClass="App\Repository\CategorieRepository")
*/
class Categorie
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $categorie_intitule;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\CategorieParent", inversedBy="categorie_id")
*/
private $categorie_parent_id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="categories")
*/
private $created_by;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Produit", mappedBy="categorie_id", orphanRemoval=true)
*/
private $produits;
CategorieParent Entity
/**
* @ORM\OneToMany(targetEntity="App\Entity\Categorie", mappedBy="categorie_parent_id", cascade={"remove"})
*/
private $categorie_id;
public function __construct()
{
$this->categorie_id = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCategorieIntitule(): ?string
{
return $this->categorie_intitule;
}
public function setCategorieIntitule(string $categorie_intitule): self
{
$this->categorie_intitule = $categorie_intitule;
return $this;
}
Tahnk you