Re: What's the best way to handle returning two queries from a component for looping?
Maybe we should start a club... :o) On Thu, May 28, 2009 at 12:02 PM, Ryan Letulle wrote: > > Don't feel bad. I never used it either. So at least there's 2 of us. > -- > Ryan > > > > On Thu, May 28, 2009 at 10:51 AM, Rick Faircloth > wrote: > > > > > Wow! That is a great function that I didn't even know existed! And how > > many > > times have a simply resorted to looping one query over another > > unnecessarily! > > And to be able to nest this multiple levels deep is great! > > > > Finally crawling out from under my rock and into the light of day! > > > > Doh! > > > > > > On Thu, May 28, 2009 at 11:21 AM, Jason Fisher wrote: > > > > > > > > It's actually been there since 4.0, I believe. I know they added the > > > groupCaseSensitive attribute in 4.5, so the group option was in place > by > > > that point. Essentially it's a way to get your output to follow your > SQL > > > groupings, when that sort of thing is necessary. So like doing a > blotter > > > style calendar, if you ORDER or GROUP the query by eventDate, you can > > then > > > cfoutput group="eventDate" to get your day-by-day headings, for > example, > > > and then cfoutput group="eventStartTime" or whatever to do a little > block > > > for each event on the blotter ... etc. They can also be nested deeper: > > > Company, Department, Individual Employee, for example. > > > > > > Jason > > > > > > > > > > > > > > > > > > > > > ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322912 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: What's the best way to handle returning two queries from a component for looping?
Always lookin to save keystrokes. :) -- Ryan On Thu, May 28, 2009 at 11:50 AM, Jason Fisher wrote: > > LOL, don't you just love finding something new that makes life (or at least > coding) easier? > > > > > ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322911 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: What's the best way to handle returning two queries from a component for looping?
LOL, don't you just love finding something new that makes life (or at least coding) easier? ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322909 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: What's the best way to handle returning two queries from a component for looping?
Don't feel bad. I never used it either. So at least there's 2 of us. -- Ryan On Thu, May 28, 2009 at 10:51 AM, Rick Faircloth wrote: > > Wow! That is a great function that I didn't even know existed! And how > many > times have a simply resorted to looping one query over another > unnecessarily! > And to be able to nest this multiple levels deep is great! > > Finally crawling out from under my rock and into the light of day! > > Doh! > > > On Thu, May 28, 2009 at 11:21 AM, Jason Fisher wrote: > > > > > It's actually been there since 4.0, I believe. I know they added the > > groupCaseSensitive attribute in 4.5, so the group option was in place by > > that point. Essentially it's a way to get your output to follow your SQL > > groupings, when that sort of thing is necessary. So like doing a blotter > > style calendar, if you ORDER or GROUP the query by eventDate, you can > then > > cfoutput group="eventDate" to get your day-by-day headings, for example, > > and then cfoutput group="eventStartTime" or whatever to do a little block > > for each event on the blotter ... etc. They can also be nested deeper: > > Company, Department, Individual Employee, for example. > > > > Jason > > > > > > > > > > > > ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322903 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: What's the best way to handle returning two queries from a component for looping?
Wow! That is a great function that I didn't even know existed! And how many times have a simply resorted to looping one query over another unnecessarily! And to be able to nest this multiple levels deep is great! Finally crawling out from under my rock and into the light of day! Doh! On Thu, May 28, 2009 at 11:21 AM, Jason Fisher wrote: > > It's actually been there since 4.0, I believe. I know they added the > groupCaseSensitive attribute in 4.5, so the group option was in place by > that point. Essentially it's a way to get your output to follow your SQL > groupings, when that sort of thing is necessary. So like doing a blotter > style calendar, if you ORDER or GROUP the query by eventDate, you can then > cfoutput group="eventDate" to get your day-by-day headings, for example, > and then cfoutput group="eventStartTime" or whatever to do a little block > for each event on the blotter ... etc. They can also be nested deeper: > Company, Department, Individual Employee, for example. > > Jason > > > > > ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322900 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: What's the best way to handle returning two queries from a component for looping?
It's actually been there since 4.0, I believe. I know they added the groupCaseSensitive attribute in 4.5, so the group option was in place by that point. Essentially it's a way to get your output to follow your SQL groupings, when that sort of thing is necessary. So like doing a blotter style calendar, if you ORDER or GROUP the query by eventDate, you can then cfoutput group="eventDate" to get your day-by-day headings, for example, and then cfoutput group="eventStartTime" or whatever to do a little block for each event on the blotter ... etc. They can also be nested deeper: Company, Department, Individual Employee, for example. Jason ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322896 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: What's the best way to handle returning two queries from a component for looping?
Thanks for the explanation, Jason. It just seems so counter-intuitive to have 's within 's...that's always been a no-no. So, was the function created to address the very problem of having to loop a query within a query? And when did CF first get this function? Recently? Or have I just completely missed that function for 10+ years? I'm just running into this as an issue now since I'm using components. Except for the use of components, I could always run two queries and then loop one within the other, so a good solution was always available. Rick On Thu, May 28, 2009 at 10:16 AM, Jason Fisher wrote: > > Rick, > > If it looks unclear, you can also do the following: > > > > #someTitleField# > > > #theDetailField# > > > > > Note that the inner CFOUTPUT has 'group' attribute, but no 'query' > attribute. The plain CFOUTPUT inside an existing query-CFOUTPUT is the > equivalent. > > ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322892 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: What's the best way to handle returning two queries from a component for looping?
Rick, If it looks unclear, you can also do the following: #someTitleField# #theDetailField# Note that the inner CFOUTPUT has 'group' attribute, but no 'query' attribute. The plain CFOUTPUT inside an existing query-CFOUTPUT is the equivalent. ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322878 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: What's the best way to handle returning two queries from a component for looping?
Thanks, Will! I don't remember using the "group" function as part of a query like that. I had always just looped one query around another. When did the "group" function show up as a query output function in CF? CF5? (Well, I guess that's what I get for going from CF 4.5 straight to CF 8...or was the "group" function in CF 4.5, too?) Another thing that confused me was using inside the . At first I left them out thinking you had made a coding error! (!!! :o) But when I took them out, the looping didn't work correctly...put them back in and it worked fine...strange...(at least to me) The help is much appreciated! Rick On Wed, May 27, 2009 at 11:58 PM, Will Tomlinson wrote: > > >I started out that way, but couldn't make a join of any type work... > > > >I tried left join, inner join, join, union, etc, but the best I could do > >was get one title with one section. There should be one title with > >multiple sections. > > Rick, > > 1. I would remove the * and reference your fieldnames. > > 2. Remove that group by n the SQL. > > 3. Your query output should look something like this: > > > > #someTitleField# > > > #theDetailField# > > > > > See if that works. > > Will > > > ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322861 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: What's the best way to handle returning two queries from a component for looping?
>I started out that way, but couldn't make a join of any type work... > >I tried left join, inner join, join, union, etc, but the best I could do >was get one title with one section. There should be one title with >multiple sections. Rick, 1. I would remove the * and reference your fieldnames. 2. Remove that group by n the SQL. 3. Your query output should look something like this: #someTitleField# #theDetailField# See if that works. Will ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322853 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: What's the best way to handle returning two queries from a component for looping?
I started out that way, but couldn't make a join of any type work... I tried left join, inner join, join, union, etc, but the best I could do was get one title with one section. There should be one title with multiple sections. Here's what I tried last: select* fromsuccess_stories ss left joinsuccess_sections sss onss.story_id = sss.story_id group byss.title order by#arguments.sort# desc How do I need to modify this to get what I need? (I've been away from the CF and SQL too long!) Thanks, Rick On Wed, May 27, 2009 at 4:20 PM, Jason Durham wrote: > > There are lots of ways to accomplish that. The simplest way seems to be > with SQL JOINs and group the output. > > > -Original Message- > From: Rick Faircloth [mailto:r...@whitestonemedia.com] > Sent: Wednesday, May 27, 2009 1:39 PM > To: cf-talk > Subject: What's the best way to handle returning two queries from a > component for looping? > > > Hi, all... > > After a *lot* of work in jQuery, specifically AJAX, I'm finally back > some > more *friendly* territory > with CF again as a focus. > > Anyway, I'm expanding my ability to use cfc methods and have just run > into a > situation where I > need to do a typical "loop one query to get a title" and "loop another > query > inside the first query > to output details from another query", so I get: > > Title 1 > - details 1 > - details 2 > - details 3 > > Title 2 > - details 1 > - details 2 > - details 3 > > Instead of: > > Title 1 > - details 1 > Title 1 > - details 2 > > etc... > > This is a no-brainer for standard "on-page" queries, but getting the > info > back from a method(s) is a little trickier. > It's a little dark in the room and so far, no light bulbs have come on > over > my head... > > Do I have to return two queries in a struct? Can I loop the structs as > I do > queries? Is this where methods and > extend other methods come into play? > > I read part of a chapter online from one of the CF8 books which seemed > to > use a getMetaData function or something > like that to loop over parts of extended functions...I didn't quite > understand that brief explanation. > > Hoping someone can point me in the right direction...approach to take? > Tutorial for this? > > Thanks for any advice. > > Rick > > -- > > > -- > "Ninety percent of the politicians give the other ten percent a bad > reputation." Henry Kissinger > > > > > ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322852 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: What's the best way to handle returning two queries from a component for looping?
There are lots of ways to accomplish that. The simplest way seems to be with SQL JOINs and group the output. -Original Message- From: Rick Faircloth [mailto:r...@whitestonemedia.com] Sent: Wednesday, May 27, 2009 1:39 PM To: cf-talk Subject: What's the best way to handle returning two queries from a component for looping? Hi, all... After a *lot* of work in jQuery, specifically AJAX, I'm finally back some more *friendly* territory with CF again as a focus. Anyway, I'm expanding my ability to use cfc methods and have just run into a situation where I need to do a typical "loop one query to get a title" and "loop another query inside the first query to output details from another query", so I get: Title 1 - details 1 - details 2 - details 3 Title 2 - details 1 - details 2 - details 3 Instead of: Title 1 - details 1 Title 1 - details 2 etc... This is a no-brainer for standard "on-page" queries, but getting the info back from a method(s) is a little trickier. It's a little dark in the room and so far, no light bulbs have come on over my head... Do I have to return two queries in a struct? Can I loop the structs as I do queries? Is this where methods and extend other methods come into play? I read part of a chapter online from one of the CF8 books which seemed to use a getMetaData function or something like that to loop over parts of extended functions...I didn't quite understand that brief explanation. Hoping someone can point me in the right direction...approach to take? Tutorial for this? Thanks for any advice. Rick -- -- "Ninety percent of the politicians give the other ten percent a bad reputation." Henry Kissinger ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322844 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
What's the best way to handle returning two queries from a component for looping?
Hi, all... After a *lot* of work in jQuery, specifically AJAX, I'm finally back some more *friendly* territory with CF again as a focus. Anyway, I'm expanding my ability to use cfc methods and have just run into a situation where I need to do a typical "loop one query to get a title" and "loop another query inside the first query to output details from another query", so I get: Title 1 - details 1 - details 2 - details 3 Title 2 - details 1 - details 2 - details 3 Instead of: Title 1 - details 1 Title 1 - details 2 etc... This is a no-brainer for standard "on-page" queries, but getting the info back from a method(s) is a little trickier. It's a little dark in the room and so far, no light bulbs have come on over my head... Do I have to return two queries in a struct? Can I loop the structs as I do queries? Is this where methods and extend other methods come into play? I read part of a chapter online from one of the CF8 books which seemed to use a getMetaData function or something like that to loop over parts of extended functions...I didn't quite understand that brief explanation. Hoping someone can point me in the right direction...approach to take? Tutorial for this? Thanks for any advice. Rick -- -- "Ninety percent of the politicians give the other ten percent a bad reputation." Henry Kissinger ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:322840 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4