It was written by Ray...

Here's the code:
        function QueryToStructOfStructures(theQuery, primaryKey){
                var theStructure = StructNew();
                // remove primary key from cols listing
                var cols =  ListToArray(ListDeleteAt(theQuery.columnlist,
ListFindNoCase(theQuery.columnlist, primaryKey)));
                var row = 1;
                var thisRow = "";
                var col  = 1;

                for(row = 1; row LTE theQuery.recordcount; row = row + 1){
                        thisRow = structnew();
                        for(col = 1; col LTE arraylen(cols); col = col + 1){
                                thisRow[cols[col]] = theQuery[cols[col]][row];
                        }
                        theStructure[theQuery[primaryKey][row]] = 
duplicate(thisRow);
                }
                return(theStructure);
        }



<!----------------//------
andy matthews
web developer
certified advanced coldfusion programmer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--------------//--------->

-----Original Message-----
From: Munson, Jacob [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 01, 2006 9:34 AM
To: CF-Talk
Subject: RE: Find in an array...


> I'm looping over what could potentially be 2500 records. I'd
> rather avoid
> converting back and forth. I ended up finding a function on
> cflib that did
> the trick.

I'm glad you found a solution, and I agree that there should be an
ArrayFind function (I was just wishing for that yesterday).  But I have
to say that 2500 array items is peanuts when you're dealing with
RAM/CPU.  I could be wrong, but I'd think it would be fairly inexpensive
to convert back and forth.  I'd take a look in that library you found to
see what it's doing...could be just as expensive as a list conversion.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:241920
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to