I just made a blog post that touches on this. May not solve every/anything, but it's related to getting queries back from DGs in different formats elegantly:
http://clearsoftware.net/client/index.cfm?mode=entry&entry=A53DF0A7-E081-2BAC-69E172A4AEC40832 -joe On Mon, 24 Jan 2005 11:19:20 +1100, Mark Mandel <[EMAIL PROTECTED]> wrote: > Some things you can think about doing differently: > > 1) Creating a Factory.cfc for your udfObject to come from, and passing > it into the DAO when it gets created, so you don't get the extra > overhead of creating a new object. > > 2) Having your DAO extend from a abstractBaseDAO.cfc, which contains > the queryRowToStruct() udf > > 3) I don't know if I would have the gateway object doing on the query > or have the query run from inside the DAO itself... because the query > would be specfic to the object... dunno... something seems weird about > that to me... > > 4) Doing your BO initialisation code like: > guideObject = createObject("component","guide").init(); > guideObject.setMemento(queryRowToStruct(guideQuery)); > > I don't personally like argument collections - and I also like having > a setMemento(), and getMemento() functions for population and cloning. > > On another note: > In regards to your alias thing - the fact that you HAVE alias's in > your table, means that you aren't tied down. > > Also, you always have the ability of creating a struct from the quey > results that matches what is required by the BO. > > You could also populate your BO through the init funciton, simply by > passing it values from the query itself: i.e. > guideObject = createObject("component","guide").init(guideQuery.IDGuide, > guideQuery.detail, guideQuery.detail2); etc. - but that does tie you > down to a single row of a table -> 1 BO model (which in most cases can > be the way it will work) > > Or you could do it through the getters and settters on the BO itself, > although there are times you want to allow setting of a value through > the init function, and not allow it to be modified, and therefore this > wouldn't be appropriate. > > There we go - some more spanners to throw in your works ;o) > > I would love to see some more discussion on how people go about > populating composite BO's from SQL results - and/or how/if they go > about populating arrays oif BO's (and arrays of composite BO's) from > SQL results. > > There are some more thoughts for you. > > Mark > > On Fri, 21 Jan 2005 15:36:20 -0900, Kirk Brogdon > <[EMAIL PROTECTED]> wrote: > > Much thanks to Nando and Mark on this - I added the queryRowToStruct method > > to a UDF component rather than inside the DAO and I'm calling it like this: > > > > guideQuery = gateWayObject.selectGuideByID(url.gu_id); > > udfObject = createObject("component","guideUDFs").init(); > > guideObject = > > createObject("component","guide").init(argumentCollection=udfObject.queryRow > > ToStruct(guideQuery)); > > > > which works great - the only problem I had was that when I built the guide > > bean I didn't use the exact same column names as the database (my db columns > > all have a gu_ prefix which I didn't bother to use in the bean). I was > > purposely trying to make it so that the bean wasn't tied specifically to the > > table (which it definitely is). It's not really a problem, I just had to > > select each column individually with an alias rather than use select * for > > the query. I guess this would be the kind of thing a "data mapper" would > > handle (but I don't think I'm ready for that yet). > > > > Thanks again - my guide is still a bit lost but at least he has flashlight. > > > > Kirk > > -- > E: [EMAIL PROTECTED] > W: www.compoundtheory.com > ICQ: 3094740 > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > > An archive of the CFCDev list is available at > www.mail-archive.com/[email protected] > -- For Tabs, Trees, and more, use the jComponents: http://clearsoftware.net/client/jComponents.cfm ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
