Я никогда не пользуюсь Symfony dans. Я читаю документацию с сайта Symfony 5 и doctrine. и некоторые видео с YouTube, и я не понимаю, мой код не работает, где моя ошибка сущности 1
/*
* @ORM\OneToMany(targetEntity="App\Entity\Review", mappedBy="id_Voyant")
*/
private $id_review;
public function __construct()
{
$this->id_review = new ArrayCollection();
}
сущность 2
private $id_Voyant;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Voyant", inversedBy="id_review")
* @ORM\JoinColumn(nullable=true)
мой репозиторий
public function findAllVisible()
{
$qb = $this->createQueryBuilder("p");
$result = $qb->addSelect('t')
->leftJoin('p.Review', 't')
->setMaxResults(5);
return $result;
}
У меня есть эта информация, а не информация в базе данных:
Doctrine\ORM\QueryBuilder {#667 ▼
-_em: Doctrine\ORM\EntityManager {#273 …11}
-_dqlParts: array:9 [▼
"distinct" => false
"select" => array:2 [▼
0 => Doctrine\ORM\Query\Expr\Select {#758 ▼
#preSeparator: ""
#postSeparator: ""
#allowedClasses: array:1 [▼
0 => "Doctrine\ORM\Query\Expr\Func"
]
#separator: ", "
#parts: array:1 [▼
0 => "p"
]
}
1 => Doctrine\ORM\Query\Expr\Select {#789 ▼
#preSeparator: ""
#postSeparator: ""
#allowedClasses: array:1 [▼
0 => "Doctrine\ORM\Query\Expr\Func"
]
#separator: ", "
#parts: array:1 [▼
0 => "t"
]
}
]
"from" => array:1 [▼
0 => Doctrine\ORM\Query\Expr\From {#759 ▼
#from: "App\Entity\Voyant"
#alias: "p"
#indexBy: null
}
]
"join" => array:1 [▼
"p" => array:1 [▼
0 => Doctrine\ORM\Query\Expr\Join {#791 ▼
#joinType: "LEFT"
#join: "p.Review"
#alias: "t"
#conditionType: null
#condition: null
#indexBy: null
}
]
]
"set" => []
"where" => null
"groupBy" => []
"having" => null
"orderBy" => []
]
-_type: 0
-_state: 0
-_dql: null
-parameters: Doctrine\Common\Collections\ArrayCollection {#793 ▼
-elements: []
}
-_firstResult: null
-_maxResults: 5
-joinRootAliases: array:1 [▼
"t" => "p"
]
#cacheable: false
#cacheRegion: null
#cacheMode: null
#lifetime: 0
}
моя веточка
{% for voyants in voyant %}
metier : {{ voyants.pseudo }}
description : {{ voyants.description }}
{% endfor %}
и контроллер
$voyant = $this->repository->findAllVisible();