This it would be your first query (approximated & untested)


$c = new Criteria();

//business join member on business.MEMBER_ID=member.ID
$c->addJoin(businessPeer::MEMBER_ID,memberPeer::ID, Criteria::LEFT_JOIN );
//left join sf_tagging on business.ID=sf_tagging.TAGGABLE_ID
$c->addJoin(businessPeer::ID, sfTaggingPeer::TAGGABLE_ID,
Criteria::LEFT_JOIN );
//left join sf_tag on (sf_tagging.TAG_ID=sf_tag.ID)
$c->addJoin(sfTagPeer::ID, sfTaggingPeer::TAG_ID, Criteria::LEFT_JOIN );


// business.NAME LIKE '%testing%'
$cton1 = $c->getNewCriterion(BusinessPeer::NAME,'%testing%',Criteria::LIKE
);
// sf_tag.TRIPLE_KEY= 'testing'
$cton2 = $c->getNewCriterion(sfTagPeer::TRIPLE_KEY,'testing',Criteria::LIKE
);
//($cton1 or $cton2)
$cton1->addOr($cton2);

// we add ($cton1 or $cton2) to main query
$c->add($cton1);

//and member.STATUS='active'
$c->addAnd(MemberPeer::status,'active');
//and business.STATUS= 'active'
$c->addAnd(BusinessPeer::STATUS,'active');
//  and sf_tagging.TAGGABLE_MODEL='Business'
$c->addAnd(sfTaggingPeer::TAGGABLE_MODEL,'Business');

$c->addGroupByColumn(sfTaggingPeer::TAGGABLE_ID);


businessPeer::doSelect($c)




On Tue, Sep 29, 2009 at 2:33 PM, Dijil <[email protected]> wrote:

>
> I am using propel. I am not an expert in using propel criteria. I
> would be thankful if you can guide me in writing this SQL as a propel
> criteria.
>
> Thx in advance,
> Dijil
>
> On Sep 29, 4:25 pm, Alexandru-Emil Lupu <[email protected]> wrote:
> > Stupid Question....
> > What ORM are you using?
> >
> > On Tue, Sep 29, 2009 at 1:17 PM, Gareth McCumskey <[email protected]
> >wrote:
> >
> >
> >
> > > You do realise of course that writing your own SQL instead of using
> your
> > > ORM's criteria objects essentially destroys any benefit you get from
> the
> > > ORM?
> >
> > > What might be more useful is to see your criteria definitions.
> >
> > > On Tue, Sep 29, 2009 at 8:43 AM, Dijil <[email protected]> wrote:
> >
> > >> Is there any way in which the below query can be modified so that I
> > >> can get all the results for the cases in which the taggable_id is null
> > >> and to group the results by taggable_id where there is taggable_id?
> >
> > >> select business.ID,business.NAME,business.CATCH_LINE,business.ADDRE
> > >> SS_ID,sf_tagging.TAGGABLE_ID from business join member on
> > >> business.MEMBER_ID=member.ID left join sf_tagging on
> > >> (business.ID=sf_tagging.TAGGABLE_ID and
> > >> sf_tagging.TAGGABLE_MODEL='Business') left join sf_tag on
> > >> (sf_tagging.TAG_ID=sf_tag.ID) where (business.NAME LIKE '%testing%' or
> > >> sf_tag.TRIPLE_KEY= 'testing') and member.STATUS='active' and
> > >> business.STATUS= 'active' group by sf_tagging.TAGGABLE_ID
> >
> > >> Thx in advance
> >
> > >> Dijil
> >
> > > --
> > > Gareth McCumskey
> > >http://garethmccumskey.blogspot.com
> > > twitter: @garethmcc
> >
> > --
> > As programmers create bigger & better idiot proof programs, so the
> universe
> > creates bigger & better idiots!
> > I am on web:  http://www.alecslupu.ro/
> > I am on twitter:http://twitter.com/alecslupu
> > I am on linkedIn:http://www.linkedin.com/in/alecslupu
> > Tel: (+4)0748.543.798
> >
>


-- 
As programmers create bigger & better idiot proof programs, so the universe
creates bigger & better idiots!
I am on web:  http://www.alecslupu.ro/
I am on twitter: http://twitter.com/alecslupu
I am on linkedIn: http://www.linkedin.com/in/alecslupu
Tel: (+4)0748.543.798

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to