this might be easier if your going to go down that way<cfquery datasource="#application.misc.dsn#" name="q_getProperties">
SELECT *
FROM re_property AS p, re_agent AS a
WHERE a.agentID = p.agentID
ORDER BY propPrice,propSuburb
</cfquery><cfset queryAddColumn(q_getProperties, "Images")><cfloop query="q_getProperties">
<cfquery datasource="#application.misc.dsn#" name="q_getImages">
SELECT *
FROM re_image
WHERE propID = #q_getProperties.propID#
</cfquery><cfset querySetCell(q_getProperties, "Images", valueList(getImages.imageURL), currentRow)>
</cfloop>If the query returns no records the valueList will be empty anyway. no need to test it to see if the query returned anything. Also, rather than going to the trouble of creating an array, populating it and then adding the column into the query after it all, may as well just populate the query as you go.
Fromreading the documentation, it had looked like the queryAddColumn function required population at the same time that it's run. That's why I did it the way I did. I've just tried your code, and sure enough I'm getting the error:
Parameter validation error for function QUERYADDCOLUMN
The function takes 3 to 4 parameters.
I managed to solve this by creating an empty array and passing that in, then overwriting it with the querySetCell further down. It seems to be working alright, but is it a fix that's likely to cause problems later?
Looking at the process though, I dont see why a join wouldnt have worked.<cfquery datasource="#application.misc.dsn#" name="q_getProperties">
SELECT *FROM re_property LEFT OUTER JOIN re_image ONre_property.propID = re_image.propID,re_agentWHERE re_agent.agentID = re_property.agentID
ORDER BY propPrice,propSuburb
</cfquery>
Because when we do something like that, if there's more than one image tied to a property it will display that property multiple times in the grid, each time with one image attached. I need exactly the oposite: each property displays only once, but knows about mutiple images if such exist.
Either way the bit at the top should cut some overhead and reduce the code your having to deal with.
It does, by lots. Thanks. :)
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
-~----------~----~----~----~------~----~------~--~---
