[transfer-dev] Transfer returns an array of objects...
... was talking to someone about a month ago about Transfer and how it always seems to return a query result rather than build an array of Transfer objects. He seems to think it was possible but I can't find anything in the documentation. Could someone maybe give me some pointers please if it can be done? Thanks again, James -- Before posting questions to the group please read: http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer Try out the new Transfer ORM Custom Google Search: http://www.google.com/cse/home?cx=002375903941309441958:2s7wbd5ocb8 You received this message because you are subscribed to the Google Groups transfer-dev group. To post to this group, send email to transfer-dev@googlegroups.com To unsubscribe from this group, send email to transfer-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/transfer-dev?hl=en
Re: [transfer-dev] Transfer returns an array of objects...
You certainly can retrieve an array of objects. If Transfer didn't, it would be far less useful. :) In Transfer, you establish your relationships (or object compositions, in some cases) in the Transfer XML config file. Here's an example... package name=car object name=Car table=tbl_Cars id name=CarID type=numeric / property name=Name type=string / onetomany name=wheels link to=car.Wheels column=Car_ID / collection type=array / /onetomany /object object name=Wheels table=tbl_Wheels id name=WheelID type=numeric / property name=Name type=string / /object /package In this case, tbl_Wheels has a FK to tbl_Cars called Car_ID. To retreive an array of wheels, you'd simply retrieve a Car from Transfer and call getWheels(). car = transfer.get('car.Car,3); // Used a fake PK of 3 if( car.containsWheels() ) { dump( car.getWheelsArray() ); } Some of that might be pseudo code off the top of my head. Check out the following 2 docs for more detailed info... http://docs.transfer-orm.com/wiki/Managing_Relationships_and_Compositions.cfm http://docs.transfer-orm.com/wiki/Generated_Methods.cfm Jason Durham On Tue, Oct 12, 2010 at 10:27 AM, Clarkee21 clarke...@gmail.com wrote: ... was talking to someone about a month ago about Transfer and how it always seems to return a query result rather than build an array of Transfer objects. He seems to think it was possible but I can't find anything in the documentation. Could someone maybe give me some pointers please if it can be done? Thanks again, James -- Before posting questions to the group please read: http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer Try out the new Transfer ORM Custom Google Search: http://www.google.com/cse/home?cx=002375903941309441958:2s7wbd5ocb8 You received this message because you are subscribed to the Google Groups transfer-dev group. To post to this group, send email to transfer-dev@googlegroups.com To unsubscribe from this group, send email to transfer-dev+unsubscr...@googlegroups.comtransfer-dev%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/transfer-dev?hl=en -- Before posting questions to the group please read: http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer Try out the new Transfer ORM Custom Google Search: http://www.google.com/cse/home?cx=002375903941309441958:2s7wbd5ocb8 You received this message because you are subscribed to the Google Groups transfer-dev group. To post to this group, send email to transfer-dev@googlegroups.com To unsubscribe from this group, send email to transfer-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/transfer-dev?hl=en
Re: [transfer-dev] Transfer returns an array of objects...
Oh... I should also mention. Just because Transfer _can_ return an array of objects, doesn't mean you should. As you probably know, object instantiation in ColdFusion comes at an expensive cost. A query is far more efficient for simple data dumping. Jason Durham On Tue, Oct 12, 2010 at 10:59 AM, Jason Durham jqdur...@gmail.com wrote: You certainly can retrieve an array of objects. If Transfer didn't, it would be far less useful. :) In Transfer, you establish your relationships (or object compositions, in some cases) in the Transfer XML config file. Here's an example... package name=car object name=Car table=tbl_Cars id name=CarID type=numeric / property name=Name type=string / onetomany name=wheels link to=car.Wheels column=Car_ID / collection type=array / /onetomany /object object name=Wheels table=tbl_Wheels id name=WheelID type=numeric / property name=Name type=string / /object /package In this case, tbl_Wheels has a FK to tbl_Cars called Car_ID. To retreive an array of wheels, you'd simply retrieve a Car from Transfer and call getWheels(). car = transfer.get('car.Car,3); // Used a fake PK of 3 if( car.containsWheels() ) { dump( car.getWheelsArray() ); } Some of that might be pseudo code off the top of my head. Check out the following 2 docs for more detailed info... http://docs.transfer-orm.com/wiki/Managing_Relationships_and_Compositions.cfm http://docs.transfer-orm.com/wiki/Generated_Methods.cfm Jason Durham On Tue, Oct 12, 2010 at 10:27 AM, Clarkee21 clarke...@gmail.com wrote: ... was talking to someone about a month ago about Transfer and how it always seems to return a query result rather than build an array of Transfer objects. He seems to think it was possible but I can't find anything in the documentation. Could someone maybe give me some pointers please if it can be done? Thanks again, James -- Before posting questions to the group please read: http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer Try out the new Transfer ORM Custom Google Search: http://www.google.com/cse/home?cx=002375903941309441958:2s7wbd5ocb8 You received this message because you are subscribed to the Google Groups transfer-dev group. To post to this group, send email to transfer-dev@googlegroups.com To unsubscribe from this group, send email to transfer-dev+unsubscr...@googlegroups.comtransfer-dev%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/transfer-dev?hl=en -- Before posting questions to the group please read: http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer Try out the new Transfer ORM Custom Google Search: http://www.google.com/cse/home?cx=002375903941309441958:2s7wbd5ocb8 You received this message because you are subscribed to the Google Groups transfer-dev group. To post to this group, send email to transfer-dev@googlegroups.com To unsubscribe from this group, send email to transfer-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/transfer-dev?hl=en
Re: [transfer-dev] Transfer returns an array of objects...
James, On Tue, Oct 12, 2010 at 11:27 AM, Clarkee21 clarke...@gmail.com wrote: ... was talking to someone about a month ago about Transfer and how it always seems to return a query result rather than build an array of Transfer objects. Jason is correct. If you have a parent object and have a relationship defined, you can retrieve an array of child objects (if you've defined the collection as an array). But I think you have something different in mind. I suspect you're not dealing with a relationship, but rather simply want an array of objects at any given time. There's no core method in Transfer to do something like: transfer.getArray(user.user). Rather, what you want to do is retrieve the query list -- transfer.list(users.user) -- or listByPropery or listByPropertyMap. This will, as you state, return a query. Then you loop over the list of IDs, creating an object matching each ID, and add them to an array. Something like: cfset var users = transfer.list(users.user) / cfset var userArray = arrayNew(1) / cfset var user = / cfif users,recordCount GT 0 cfloop query=users cfset user = transfer.get(users.user,users.UserID) / (This creates the object) cfset arrayAppend(userArray,user) / /cfloop /cfif cfreturn userArray / Make sense? -- Thanks, Tom Tom McNeer MediumCool http://www.mediumcool.com 1735 Johnson Road NE Atlanta, GA 30306 404.589.0560 -- Before posting questions to the group please read: http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer Try out the new Transfer ORM Custom Google Search: http://www.google.com/cse/home?cx=002375903941309441958:2s7wbd5ocb8 You received this message because you are subscribed to the Google Groups transfer-dev group. To post to this group, send email to transfer-dev@googlegroups.com To unsubscribe from this group, send email to transfer-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/transfer-dev?hl=en