0
私はリポジトリ から私のプロダクトを取得しようとしている登録しよう存在 " 質問ビルダーで何が問題になっていますか? おかげsymfonyのcreateQueryBuilder私は3つのテーブルを持っている
は、私はスクリーンショットを追加し、[OK]class ProduitsRepository extends \Doctrine\ORM\EntityRepository {
public function byCategorie($categorie) {
$qb = $this->createQueryBuilder('p')
->select('p') // Entity Produits
->join('p.type', 't')
->addSelect('t') // Entity Types
->where('p.type = t.id AND t.categorie = :categorie')
->orderBy('p.id')
->setParameter('categorie', $categorie);
return $qb->getQuery()->getResult();
}
}
は enter image description here
これは、これは私の小枝ビューproduits.html.twigである私のコントローラ
public function categorieAction($categorie)
{
$em = $this->getDoctrine()->getManager();
$produits = $em->getRepository('GbaBundle:Produits')->byCategorie($categorie);
return $this->render('GbaBundle:Default:produits/layout/produits.html.twig', array(
'produits' => $produits
));
}
ある
<ul class="thumbnails">
{% for produit in produits %}
<li class="span3">
<div class="thumbnail">
<img src="{{ asset('img/holder.png') }}" alt="" width="300" height="300">
<div class="caption">
<h4>Thumbnail label</h4>
<p>100,00 €</p>
<a class="btn btn-primary" href="{{ path('gba_presentation') }}">Plus d'infos</a>
<a class="btn btn-success" href="{{ path('gba_panier') }}">Ajouter au panier</a>
</div>
</div>
</li>
{% endfor %}
</ul>
okスクリーンショットとコードを追加しました – wildnano
@wildnano私は自分の答えを編集しました。 –
Right Thanks - 悪いメソッドが私のルーティングで呼び出されました。レンダーで配列を消去しました:array( 'produits' => $ produits)); $ em = $ this-> getDoctrine() - > getManager(); $ produits = $ em-> getRepository( 'GbaBundle:Produits') - > findAll(); – wildnano