[transfer-dev] Re: Convert array of transfer objects to query

2009-06-17 Thread Mark Mandel
Change it to use StructKeyArray() on the CFC, and look at the keys on the
CFC that way, rather than getMetaData(). Should be easy enough to do.

Mark

On Wed, Jun 17, 2009 at 8:41 PM, Dan O'Keefe dan.oke...@gmail.com wrote:

 On Tue, Jun 16, 2009 at 2:33 PM, Don Quist don.sigmaproje...@gmail.comwrote:

 http://www.cflib.org/udf/arrayOfObjectsToQuery

 I always prefer to use objects, but recently I worked on a project where
 all kinds of remote access was required.   json, wddx, amf, etc.  Since
 cfc's have a hard time getting serialized, and when objects have extensive
 inheritance, wddx conversion gets bloated.  I came up with the above
 function that I didn't end up using because I didn't like the eval.

 In anycase, I was thinking you could thread out a job to convert the array
 of objects to a cfquery then cache it.   Maybe setup an event, whenever an
 object is modified and saved, update the cached object as well?

 Hi Don,
 My initial post regarding this subject mentioned your UDF. The issue I had
 when using it with Transfer is the getMetadata call returns the functions in
 the decorator, so it does not return the getters needed to work. If I was
 over riding all of my getters and setters in the decorator it would work,
 but otherwise it would not. Insightful UDF though.

 Thanks,

 Dan

 



-- 
E: mark.man...@gmail.com
W: www.compoundtheory.com

--~--~-~--~~~---~--~~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

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



[transfer-dev] Re: Convert array of transfer objects to query

2009-06-16 Thread Dan O'Keefe
I figured these would be some of the responses, and that is why I stated  I
know there are other ways to return the query via transfer, but this one
intrigued me. :)
Probably more that it intrigues me and was looking for a way to do it. If I
already have my array of TO's used elsewhere and need an occasional place to
convert it to a query, this seems like a better way to go for me. Allows me
to keep my gateways cleaner and not polluted with a ton of TQL or cfquery
calls just to fit every little need that is a little different. I realize
also the TQL is cache'd by default also.

I am still refining over time the architecture of CB/CS/Transfer apps and
what way I think it works best for me and performance and in a way that I
can carry over from app to app, so this is one that popped up as something I
would like to have.

Thanks
--
Dan O'Keefe


On Mon, Jun 15, 2009 at 7:15 PM, Mark Mandel mark.man...@gmail.com wrote:

 Yeah... I'm curious about the use case as well! ;o) What's the reason?

 Mark

 On Tue, Jun 16, 2009 at 5:57 AM, Chris Peterson overrid...@gmail.comwrote:

  Is there a reason that you did not just get a list rather than using
 objects to begin with, or just write plain jane SQL statements to get what
 you need? Raw SQL is still one of the fastest ways to get data from the
 database, objects and tql are really (imo) when you want your rich business
 object logic attached, or when you want to make use of the cache or
 relationships.  If you just need a query, then cfquery can be your best
 friend (put it in an object decorator, which is still a great way to toss
 that logic around)

 Chris Peterson


 On 6/15/09 3:52 PM, Dan O'Keefe dan.oke...@gmail.com wrote:

 I am sure this must have been discussed already, but a search did not
 yield any results.

 I was looking for a UDF to convert an array of transfer objects to a
 query. I was looking at http://cflib.org/udf/arrayOfObjectsToQuery which
 uses the CF getMetaData() function and is looking for getter functions. But,
 I am trying to use it in a TO o2m array, the getmetaData only returns the
 functions in the decorator.

 Anyone know of such an animal? I know there are other ways to return the
 query via transfer, but this one intrigued me.

 Thanks,

 Dan









 --
 E: mark.man...@gmail.com
 W: www.compoundtheory.com


 


--~--~-~--~~~---~--~~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

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



[transfer-dev] Re: Convert array of transfer objects to query

2009-06-16 Thread Matt Williams

On Jun 16, 9:21 am, Dan O'Keefe dan.oke...@gmail.com wrote:
 On Tue, Jun 16, 2009 at 8:39 AM, Bob Silverberg 
 bob.silverb...@gmail.comwrote:

  It seems to me that the main reason that one would use a query over a
  collection of objects is for performance - to save the cost of creating all
  of those objects.  So if you already have a collection of objects, why would
  you want to convert them back to a query?  It seems like you'd be losing
  functionality and not gaining anything in terms of performance.

  What sort of things would you be looking to do with a query that you cannot
  do, or wouldn't choose to do, with a collection of objects?

 Unless I am mistaken, I was thinking it would be the other way around. If I
 already have cached objects I use in other places, would be quicker to
 convert to a query, versus a hit to the database.  I know the TQL is cached
 after the first hit, but a DB call versus converting it in memory.


I think Bob meant that if you already have the array of objects, why
convert it to a query? Why not just return the array of objects and
use the array in your view? No conversion, no DB hit.

Matt Williams
--~--~-~--~~~---~--~~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

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



[transfer-dev] Re: Convert array of transfer objects to query

2009-06-16 Thread Sean Coyne

Seems odd to want to make it a query but you could do something like
this.  I havent tested this.  Assuming your array of objects is called
arrayOfObj:

cfset q = queryNew(structKeylist(arrayofObj[1].getMemento())) /
cfloop array=#arrayOfObjs# index=obj
cfset queryAddRow(q) /
cfset s = obj.getMemento() /
cfloop collection=#s# item=col
cfset querySetCell(q,col,s[col]) /
/cfloop
/cfloop
cfdump var=#q# /

On Jun 16, 9:21 am, Dan O'Keefe dan.oke...@gmail.com wrote:
 On Tue, Jun 16, 2009 at 8:39 AM, Bob Silverberg 
 bob.silverb...@gmail.comwrote:

  It seems to me that the main reason that one would use a query over a
  collection of objects is for performance - to save the cost of creating all
  of those objects.  So if you already have a collection of objects, why would
  you want to convert them back to a query?  It seems like you'd be losing
  functionality and not gaining anything in terms of performance.

  What sort of things would you be looking to do with a query that you cannot
  do, or wouldn't choose to do, with a collection of objects?

 Unless I am mistaken, I was thinking it would be the other way around. If I
 already have cached objects I use in other places, would be quicker to
 convert to a query, versus a hit to the database.  I know the TQL is cached
 after the first hit, but a DB call versus converting it in memory.

 I would use it where it makes more sense based on the display of data on
 more complicated forms. Also tens to be a little more readable
 for other developers.

 Dan
--~--~-~--~~~---~--~~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

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



[transfer-dev] Re: Convert array of transfer objects to query

2009-06-16 Thread Don Quist
http://www.cflib.org/udf/arrayOfObjectsToQuery

I always prefer to use objects, but recently I worked on a project where all
kinds of remote access was required.   json, wddx, amf, etc.  Since cfc's
have a hard time getting serialized, and when objects have extensive
inheritance, wddx conversion gets bloated.  I came up with the above
function that I didn't end up using because I didn't like the eval.

In anycase, I was thinking you could thread out a job to convert the array
of objects to a cfquery then cache it.   Maybe setup an event, whenever an
object is modified and saved, update the cached object as well?


On Tue, Jun 16, 2009 at 11:09 AM, Matt Williams mgw...@gmail.com wrote:


 On Jun 16, 9:21 am, Dan O'Keefe dan.oke...@gmail.com wrote:
  On Tue, Jun 16, 2009 at 8:39 AM, Bob Silverberg 
 bob.silverb...@gmail.comwrote:
 
   It seems to me that the main reason that one would use a query over a
   collection of objects is for performance - to save the cost of creating
 all
   of those objects.  So if you already have a collection of objects, why
 would
   you want to convert them back to a query?  It seems like you'd be
 losing
   functionality and not gaining anything in terms of performance.
 
   What sort of things would you be looking to do with a query that you
 cannot
   do, or wouldn't choose to do, with a collection of objects?
 
  Unless I am mistaken, I was thinking it would be the other way around. If
 I
  already have cached objects I use in other places, would be quicker to
  convert to a query, versus a hit to the database.  I know the TQL is
 cached
  after the first hit, but a DB call versus converting it in memory.
 

 I think Bob meant that if you already have the array of objects, why
 convert it to a query? Why not just return the array of objects and
 use the array in your view? No conversion, no DB hit.

 Matt Williams
 



-- 
- Don Quist
www.SigmaProjects.org

--~--~-~--~~~---~--~~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

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



[transfer-dev] Re: Convert array of transfer objects to query

2009-06-15 Thread Chris Peterson
Is there a reason that you did not just get a list rather than using objects
to begin with, or just write plain jane SQL statements to get what you need?
Raw SQL is still one of the fastest ways to get data from the database,
objects and tql are really (imo) when you want your rich business object
logic attached, or when you want to make use of the cache or relationships.
If you just need a query, then cfquery can be your best friend (put it in
an object decorator, which is still a great way to toss that logic around)

Chris Peterson


On 6/15/09 3:52 PM, Dan O'Keefe dan.oke...@gmail.com wrote:

 I am sure this must have been discussed already, but a search did not yield
 any results.
 
 I was looking for a UDF to convert an array of transfer objects to a query. I
 was looking at http://cflib.org/udf/arrayOfObjectsToQuery which uses the CF
 getMetaData() function and is looking for getter functions. But, I am trying
 to use it in a TO o2m array, the getmetaData only returns the functions in the
 decorator.
 
 Anyone know of such an animal? I know there are other ways to return the query
 via transfer, but this one intrigued me.
 
 Thanks,
 
 Dan
 
 
  
 


--~--~-~--~~~---~--~~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

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