Message from discussion
ManytoMany Join with foreign table and Association Filtering Criteria
Received: by 10.42.211.71 with SMTP id gn7mr6760163icb.11.1352472082966;
Fri, 09 Nov 2012 06:41:22 -0800 (PST)
X-BeenThere: doctrine-user@googlegroups.com
Received: by 10.50.41.194 with SMTP id h2ls1130210igl.4.canary; Fri, 09 Nov
2012 06:41:10 -0800 (PST)
Received: by 10.50.41.132 with SMTP id f4mr1032481igl.1.1352472070311;
Fri, 09 Nov 2012 06:41:10 -0800 (PST)
Received: by 10.50.41.132 with SMTP id f4mr1032478igl.1.1352472070236;
Fri, 09 Nov 2012 06:41:10 -0800 (PST)
Return-Path: <vincent.waste...@gmail.com>
Received: from mail-ob0-f177.google.com (mail-ob0-f177.google.com [209.85.214.177])
by gmr-mx.google.com with ESMTPS id uk11si202570igb.2.2012.11.09.06.41.10
(version=TLSv1/SSLv3 cipher=OTHER);
Fri, 09 Nov 2012 06:41:10 -0800 (PST)
Received-SPF: pass (google.com: domain of vincent.waste...@gmail.com designates 209.85.214.177 as permitted sender) client-ip=209.85.214.177;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of vincent.waste...@gmail.com designates 209.85.214.177 as permitted sender) smtp.mail=vincent.waste...@gmail.com; dkim=pass header...@gmail.com
Received: by mail-ob0-f177.google.com with SMTP id wd20so5389325obb.22
for <doctrine-user@googlegroups.com>; Fri, 09 Nov 2012 06:41:10 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to
:content-type;
bh=JH0Irblia2YQQtS7FdkAS369ugRk9BHpw+N4ixUkohk=;
b=v+xAKaUB5WqMc/mxJPYxpRukchPorCH/895OjvJGydhLJ+NWtrP0ArgsBH1r0hcsX+
tQY0/UXw/7W0ap/BzegQeNJga+bIIerPzhYAkB9GVWG6PYYO1D4yOpg820++1vllg92O
ZzumWJZbl/TvSmdzMdiAXMLyZbK0HfVlpmavMFx0mCsYdvMFGl/kyc3Iyoo2+UZ48sWj
CFCuWdm5RQHPaPiH3R02K9qB5GctvwDtKygOda4cYsPPwYPFm9M57bhY2J+FTnYe69QZ
LHpQXCyKZIDnbCyJG7eM6HbCSeqOjBppS3OSo0qFwTS5lQNJa8pF9k31f/n87XMBgAFU
QKBw==
Received: by 10.60.25.132 with SMTP id c4mr7936547oeg.63.1352472070058; Fri,
09 Nov 2012 06:41:10 -0800 (PST)
MIME-Version: 1.0
Received: by 10.76.153.162 with HTTP; Fri, 9 Nov 2012 06:40:49 -0800 (PST)
In-Reply-To: <509C437C.4090...@gmail.com>
References: <0945a83d-f021-4702-9d69-017bda0ea8ef@googlegroups.com>
<6075ba46-09c5-4e84-8b5c-c4f6cb1e9a59@googlegroups.com> <74462c8d-0c6e-4e97-b9fa-03408f081cdf@googlegroups.com>
<509C437C.4090...@gmail.com>
From: Vincent Wasteels <vincent.waste...@gmail.com>
Date: Fri, 9 Nov 2012 09:40:49 -0500
Message-ID: <CALS5miHvgaoN9iXV=xTKeAjxUnHNqEpuw-Ug+Hm-AAvAJe-...@mail.gmail.com>
Subject: Re: [doctrine-user] Re: ManytoMany Join with foreign table and
Association Filtering Criteria
To: doctrine-user@googlegroups.com
Content-Type: multipart/alternative; boundary=e89a8ff1c7cc4df2fe04ce10f155
--e89a8ff1c7cc4df2fe04ce10f155
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hello !
it gives me the join table , that's my problem ...
2012/11/8 Gregory McLean <cent...@gmail.com>
> On 11/08/2012 05:28 PM, Vincent Wasteels wrote:
> > Hello, thx for ur answer !!
> >
> > I'm using a third table for the relation and some extra fields , so I
> can't
> > just do $this->article
> >
> > I can access : $this->categoryArticle , but the attribute I have to
> filter
> > is in Article itself ...
> >
>
> So $this->categoryArticle() gives you your article entity or the
> join_table entity?
>
> > I'm stuck on this ... !
> >
> > thanks for ur help !! much appreciated !
> >
> >
> > Le jeudi 8 novembre 2012 16:33:40 UTC-5, Gregory McLean a =E9crit :
> >>
> >> In your category entity use the collection criteria, and something lik=
e
> >> (I'm paging the results)
> >>
> >> public function getRelatedArticles($start =3D 0, $limit =3D 10)
> >> {
> >> $criteria =3D Criteria::create()
> >> ->where('ispublished =3D true');
> >>
> >> return $this->articles->matching($criteria);
> >> }
> >>
> >> Then in the article entity add the @OrderBy annotation on the manytoma=
ny
> >> bit
> >>
> >> @ManyToMany(<blah blah blah>)
> >> @OrderBy("created" =3D "ASC|DESC")
> >>
> >> Then it _should_ do what you want when in the template you do
> >>
> >> {% for related in article.category.relatedarticles %}
> >> {{ related.name }}
> >> {% endfor %}
> >>
> >> This of course is if I'm understanding how you have all the entities
> >> mapped.
> >>
> >>
> >> On Thursday, November 8, 2012 11:52:41 AM UTC-5, Vincent Wasteels wrot=
e:
> >>>
> >>> Hello doctrine !!
> >>>
> >>> I have a model like this :
> >>>
> >>> Article 1.* ArticleCategory *.1 Category
> >>>
> >>> In my Category Entity, I want to get all article related to $this ,
> >>> orderBy article.created and where article.published is true ,
> >>>
> >>> I could do :
> >>>
> >>> $articles =3D array();
> >>> foreach($this->getArticleCategory() as $art_cat){
> >>> $article =3D $art_cat->getArticle();
> >>> if($article->isPublished()) $articles[] =3D $article;
> >>> }
> >>>
> >>> But It won't deal the orderBy, and it seems too heavy anyway...
> >>>
> >>> The Criteria from Doctrine Collection is more appropriated but I don'=
t
> >>> see how to handle the relation table,
> >>>
> >>> and I don't want to do this in a repository since it concerns a
> specific
> >>> Category,
> >>>
> >>> Any hints for me ?
> >>>
> >>> thanks !!
> >>>
> >>
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "doctrine-user" group.
> To post to this group, send email to doctrine-user@googlegroups.com.
> To unsubscribe from this group, send email to
> doctrine-user+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/doctrine-user?hl=3Den.
>
>
--e89a8ff1c7cc4df2fe04ce10f155
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hello !<div><br></div><div>it gives me the join table , that's my probl=
em ...=A0</div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote=
">2012/11/8 Gregory McLean <span dir=3D"ltr"><<a href=3D"mailto:centove@=
gmail.com" target=3D"_blank">cent...@gmail.com</a>></span><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div class=3D"im">On 11/08/2012 05:28 PM, Vi=
ncent Wasteels wrote:<br>
> Hello, thx for ur answer !!<br>
><br>
> I'm using a third table for the relation and some extra fields , s=
o I can't<br>
> just do $this->article<br>
><br>
> I can access : $this->categoryArticle , but the attribute I have to=
filter<br>
> is in Article itself ...<br>
><br>
<br>
</div>So $this->categoryArticle() gives you your article entity or the<b=
r>
join_table entity?<br>
<div class=3D"HOEnZb"><div class=3D"h5"><br>
> I'm stuck on this ... !<br>
><br>
> thanks for ur help !! much appreciated !<br>
><br>
><br>
> Le jeudi 8 novembre 2012 16:33:40 UTC-5, Gregory McLean a =E9crit :<br=
>
>><br>
>> In your category entity use the collection criteria, and something=
like<br>
>> (I'm paging the results)<br>
>><br>
>> public function getRelatedArticles($start =3D 0, $limit =3D 10)<br=
>
>> {<br>
>> $criteria =3D Criteria::create()<br>
>> =A0 =A0 =A0 =A0 =A0 =A0 ->where('ispublished =3D true')=
;<br>
>><br>
>> return $this->articles->matching($criteria);<br>
>> }<br>
>><br>
>> Then in the article entity add the @OrderBy annotation on the many=
tomany<br>
>> bit<br>
>><br>
>> @ManyToMany(<blah blah blah>)<br>
>> @OrderBy("created" =3D "ASC|DESC")<br>
>><br>
>> Then it _should_ do what you want when in the template you do<br>
>><br>
>> {% for related in article.category.relatedarticles %}<br>
>> =A0 =A0 {{ <a href=3D"http://related.name" target=3D"_blank">relat=
ed.name</a> }}<br>
>> {% endfor %}<br>
>><br>
>> This of course is if I'm understanding how you have all the en=
tities<br>
>> mapped.<br>
>><br>
>><br>
>> On Thursday, November 8, 2012 11:52:41 AM UTC-5, Vincent Wasteels =
wrote:<br>
>>><br>
>>> Hello doctrine !!<br>
>>><br>
>>> I have a model like this :<br>
>>><br>
>>> Article 1.* ArticleCategory *.1 Category<br>
>>><br>
>>> In my Category Entity, I want to get all article related to $t=
his ,<br>
>>> orderBy article.created and where article.published is true ,<=
br>
>>><br>
>>> I could do :<br>
>>><br>
>>> $articles =3D array();<br>
>>> foreach($this->getArticleCategory() as $art_cat){<br>
>>> =A0 =A0 $article =3D $art_cat->getArticle();<br>
>>> =A0 =A0 if($article->isPublished()) $articles[] =3D $articl=
e;<br>
>>> }<br>
>>><br>
>>> But It won't deal the orderBy, and it seems too heavy anyw=
ay...<br>
>>><br>
>>> The Criteria from Doctrine Collection is more appropriated but=
I don't<br>
>>> see how to handle the relation table,<br>
>>><br>
>>> and I don't want to do this in a repository since it conce=
rns a specific<br>
>>> Category,<br>
>>><br>
>>> Any hints for me ?<br>
>>><br>
>>> thanks !!<br>
>>><br>
>><br>
><br>
<br>
--<br>
You received this message because you are subscribed to the Google Groups &=
quot;doctrine-user" group.<br>
</div></div><div class=3D"HOEnZb"><div class=3D"h5">To post to this group, =
send email to <a href=3D"mailto:doctrine-user@googlegroups.com">doctrine-us=
er@googlegroups.com</a>.<br>
To unsubscribe from this group, send email to <a href=3D"mailto:doctrine-us=
er%2Bunsubscribe@googlegroups.com">doctrine-user+unsubscr...@googlegroups.c=
om</a>.<br>
For more options, visit this group at <a href=3D"http://groups.google.com/g=
roup/doctrine-user?hl=3Den" target=3D"_blank">http://groups.google.com/grou=
p/doctrine-user?hl=3Den</a>.<br>
<br>
</div></div></blockquote></div><br></div>
--e89a8ff1c7cc4df2fe04ce10f155--