HY,
我尝试为我的网站制作搜索引擎,但是在2个不同的实体中。在第一个我正在寻找'ville',在第二个''matiere',我想要匹配的idtutor!
我的控制器:
public function resultat($ville, $matiere)
{
$info = array();
$em = $this->getDoctrine()->getManager();
$repository = $em->getRepository('AppBundle:tutor1');
$listAdverts = $repository->findBy(array('ville' => $ville));
foreach ($listAdverts as $advert) {
$advert->getIdTutor();
$repository = $em->getRepository('AppBundle:matiere');
$listAdverts = $repository->findBy(array('matiere' => $matiere, 'id_tutor' => $advert->getIdTutor()));
foreach ($listAdverts as $advert) {
$idtutor = $advert->getIdTutor();
$repository = $em->getRepository('AppBundle:User');
$info1 = $repository->findBy(array('id' => $idtutor));
$repository2 = $em->getRepository('AppBundle:tutor2');
$info2 = $repository2->findBy(array('id_tutor' => $idtutor));
$info = array(
'info1' => $info1,
'info2' => $info2);
}
}
return $this->render('/rechercher-un-tuteur.html.twig', $info);
}
前面,我的树枝:
{% if info1|length > 0 %}
{% for tutor in info1 %}
<h5> prénom : {{ tutor.FirstName }} </h5>
{% for tutor2 in info2 %}
<p> {{ tutor2.PresentationTutor }} </p>
{% endfor %}
{% endfor %}
{% else %}
<li>Pas (encore !) de Tuteur</li>
{% endif %}
但我刚出现的最后一位导师......你有什么想法吗? 认为