Re: What's the best way to handle returning two queries from a component for looping?

2009-05-28 Thread Rick Faircloth

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 cfoutput/cfoutput inside the
cfoutput query =   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 w...@wtomlinson.comwrote:


 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:

 cfoutput query=getStuff group=theTitleFieldHere

 h1#someTitleField#/h1

  cfoutput
  p#theDetailField#/p
  /cfoutput

 /cfoutput

 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?

2009-05-28 Thread Jason Fisher

Rick,

If it looks unclear, you can also do the following:

cfoutput query=getStuff group=theTitleFieldHere

h1#someTitleField#/h1

cfoutput group=theDetailField
p#theDetailField#/p
/cfoutput

/cfoutput

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?

2009-05-28 Thread Rick Faircloth

Thanks for the explanation, Jason.

It just seems so counter-intuitive to have cfoutput's within
cfoutput's...that's
always been a no-no.

So, was the cfoutput group... 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 ja...@wanax.com wrote:


 Rick,

 If it looks unclear, you can also do the following:

 cfoutput query=getStuff group=theTitleFieldHere

 h1#someTitleField#/h1

 cfoutput group=theDetailField
 p#theDetailField#/p
 /cfoutput

 /cfoutput

 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?

2009-05-28 Thread Jason Fisher

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?

2009-05-28 Thread Rick Faircloth

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 ja...@wanax.com 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?

2009-05-28 Thread Ryan Letulle

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
r...@whitestonemedia.comwrote:


 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 ja...@wanax.com 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?

2009-05-28 Thread Jason Fisher

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?

2009-05-28 Thread Ryan Letulle

Always lookin to save keystrokes. :)
--
Ryan



On Thu, May 28, 2009 at 11:50 AM, Jason Fisher ja...@wanax.com 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?

2009-05-28 Thread Rick Faircloth

Maybe we should start a club... :o)


On Thu, May 28, 2009 at 12:02 PM, Ryan Letulle bayous...@gmail.com 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
 r...@whitestonemedia.comwrote:

 
  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 ja...@wanax.com 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?

2009-05-27 Thread Jason Durham

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


Re: What's the best way to handle returning two queries from a component for looping?

2009-05-27 Thread Rick Faircloth

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 jdur...@cti-stl.com 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?

2009-05-27 Thread Will Tomlinson

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:

cfoutput query=getStuff group=theTitleFieldHere

h1#someTitleField#/h1

  cfoutput
  p#theDetailField#/p
  /cfoutput

/cfoutput

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