Bonjour,
Voila je rencontre un petit problème avec mon code.
Voici mon fichier Twig
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 /** * @Route("/recherche_prod_titre_desc", name="recherche_prod_titre_desc") */ public function rechercherProduitParTitreOuDescAction() { $dql = "SELECT p FROM AppBundle:Produit p WHERE p.titre LIKE :monTitre OR p.description LIKE :description"; $query = $this->getDoctrine()->getManager()->createQuery($dql); $query->setParameter("monTitre", "%ka%"); $query->setParameter("description", "%9%"); $produits = $query->getResult(); return $this->render("AppBundle:Test:lister_produits.html.twig", array('mesProduits' => $produits, 'titre' => "Tous les produits" )); }
Voici la requete que sf execute
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 {% extends 'base.html.twig' %} {% block body %} {{titre}} {% for prodAct in mesProduits %} Produit actuel: {{ prodAct.titre }} Description : {{ prodAct.description }} Prix : {{ prodAct.prix }} Stock : {{ prodAct.stock }} {% for catAct in prodAct.categories %} Categorie : {{ catAct.titre }} {% endfor %} {% endfor %} {% endblock %}
SELECT p0_.id AS id_0, p0_.titre AS titre_1, p0_.description AS description_2, p0_.prix AS prix_3, p0_.stock AS stock_4 FROM produit p0_ INNER JOIN produits_commandes p2_ ON p0_.id = p2_.produit_id INNER JOIN commande c1_ ON c1_.id = p2_.commande_id INNER JOIN client c3_ ON c1_.client_id = c3_.id WHERE c3_.login LIKE "%wa%" AND p0_.prix BETWEEN 0 AND 20000005
Il me retourne 3 résultats via ma base :
4 Desert Eagle .50 3000 10
9 Bazooka NULL 5000 2
4 Desert Eagle .50 3000 10
Ce que j'obtiens
Tous les produits
Produit actuel: Desert Eagle Description : .50 Prix : 3000 Stock : 10 Categorie : Armes Poing
Produit actuel: Bazooka Description : Prix : 5000 Stock : 2 Categorie : Armes Lourdes
Merci Beaucoup pour votre aide sur le sujet
Pour résumer il me fait un DISTINCT alors qu'il ne devrait pas
Partager