I hadn't thought of doing it that way, but it makes a whole lot of sense. Thanks for that, I'll have a fiddle with it and see if I can get it going this way. :)

Cheers,

Seona.

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

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


--~--~---------~--~----~------------~-------~--~----~
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