the thing is your doing queries where they are not needed

all you needed to do was do what your doing with the query, but create a
whole new query instead of populating a new field

for example

//////////////////////////////////////////////////////////////////////
<!--- Get all the properties and any images relating to them --->
<cfquery datasource="#application.misc.dsn#" name="q_getProperties">
    SELECT      re_property.*, re_image.imageURL
    FROM        re_property LEFT OUTER JOIN re_image ON
               re_property.propID = re_image.propID,
                re_agent
    WHERE   re_agent.agentID = re_property.agentID
    ORDER BY    propPrice,propSuburb
</cfquery>

<!--- create a new query object to populate --->
<cfset properties = queryNew("#q_getProperties.columnList#,Images")>

<!--- Output the query grouping by the property so we don't get doubles --->
<cfoutput query="q_getProperties" group="propID">

        <!-- add a row to the query object --->
        <cfset queryAddRow(properties)>

        <!--- loop over the columns in the r
        <cfloop list="#q_getProperties.columnList#" index="c">
                <cfif c NEQ "imageURL">
                        <cfset querySetCell(properties, c, evaluate(c))>
                </cfif>
        </cfloop>

        <!--- rest the property images value --->
        <cfset propertyImages = "">

        <!--- add the properties together --->
        <cfoutput>
                <cfset propertyImages = listAppend(propertyImages, imageURL)>
        </cfoutput>

        <!--- set the property image cell with the total list of images --->
        <cfset querySetCell(properties, "Images", propertyImages)>

</cfoutput>
//////////////////////////////////////////////////////////////////////

That's how I would have done it anyway, otherwise your hitting the database
over and over just to get the images for the property.  Just think, you have
20 properties with say 5 images each, that's 101 database queries to do what
you need to do.  This way is only a single query and your letting CF do the
grunt work to put it into the format you need.

Steve

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] Behalf
Of Seona Bellamy
Sent: Tuesday, March 28, 2006 9:53 AM
To: [email protected]
Subject: [cfaussie] Re: Dealing with a random number of images


On 28/03/06, Steve Onnis <[EMAIL PROTECTED]> wrote:
Sorry

Should be just
<cfset queryAddColumn(q_getProperties, "Images", arrayNew(1))>

Ah, that's easier than the way I did it. Changing it now. :)



When it returns multiple items, that's when you use the "group" attributre
for the CFOUTPUT tag.
<cfoutput group="popID">
      #property#
      <cfoutput>output the images</cfoutput>
</cfoutput>


I'd tried that, but it was causing problems since I'm integrating it into a
Flash form instead of just outputting it directly like I normally would. It
seems that bindings don't play well with just about anything. :( So the
solution I've got now seems to cover what I need, and I've even got the
detail display working right (finally)! I feel good. *grin*

Cheers,

Seona.




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cfaussie" 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/cfaussie
-~----------~----~----~----~------~----~------~--~---

Reply via email to