Query question

18 views
Skip to first unread message

raulriera

unread,
Nov 25, 2009, 2:33:29 PM11/25/09
to ColdFusion on Wheels
Hi,

Although this is not a "Wheels" question (sorry about this), this is
where I get the best support :) I am trying to make a Catalog of
Products where there are "tags" attached to each one of the
products... now I would like to do the same

/products/[tag1]

Will filter all products tagged with [tag1]

/products/[tag1]/[tag2]

Will filter all products tagged with [tag1] AND [tag2], currently I
can get all products tagged with [tag1] OR [tag2].. any ideas how the
SQL would work for this? (I don't care if the ORM won't do)

My current code looks like this:

<cfset loc.tagsId = model("Tag").findAll(select="id", where="name =
'#humanize(params.tag1)#' OR name = '#humanize(params.tag2)#'")>

<!--- Find all the products for the given tags --->
<cfset products = model("Product").findAll(distinct=true,
select="products.*", where="tagId IN (#ValueList(loc.tagsId.id)#)",
include="producttags", order="price DESC")>

Of course, if there is a better way :) show me the light hehe

raulriera

unread,
Nov 26, 2009, 1:17:39 AM11/26/09
to ColdFusion on Wheels
On a related note... I found a bug in CF (both Adobe and Railo I
believe) the QoQ won't remove duplicates with an UNION, but doing the
SAME SQL on mySQL it will remove the duplicates all right... (where
can I submit this?)

Per Djurner

unread,
Nov 26, 2009, 9:24:18 AM11/26/09
to cfwh...@googlegroups.com
Would something like this not work?
<cfset products = model("product").findAll(where="name='x' OR name='x'", include="producttags(tag)", order="price DESC")>


--

You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.



Chris Peters

unread,
Nov 26, 2009, 11:32:07 AM11/26/09
to cfwh...@googlegroups.com
CF Bug Tracker:
http://www.adobe.com/go/CF_bugs

raulriera

unread,
Nov 26, 2009, 2:44:46 PM11/26/09
to ColdFusion on Wheels
I guess that should work... but it's giving me that weird error that
the association is not setup with Tag :S
> > cfwheels+u...@googlegroups.com<cfwheels%2Bunsubscribe@googlegroups.c om>
> > .
Reply all
Reply to author
Forward
0 new messages