I wrote this a long time ago as a proof-of-concept when I was trying
to figure out how to store arrays in client vars.  Substitute my query
for yours.  Something simple with a field or two.

Clearly if you need to store a structure in a persistent scope there
are better ways to do it, but this shows how its done if you *must* do
it in cvars.


<!--- pull the query --->
<cfquery 
        username="#request.UserName#"
        password="#request.Password#" 
        name="ShowGroups" 
        datasource="#request.DSN#">
        SELECT
                groups.ID,
                groups.GroupName
        FROM groups
        WHERE 
                0=0
</cfquery>
<!--- create the local 2d array from the query --->
<CFSET variables.MyArray = ArrayNew(2)>
<cfloop query="ShowGroups">
        <CFSET variables.MyArray[ShowGroups.CurrentRow][1]=ShowGroups.ID>
        <CFSET variables.MyArray[ShowGroups.CurrentRow][2]=ShowGroups.GroupName>
        <CFSET variables.MyArray[ShowGroups.CurrentRow][3]="blah">
        <CFSET variables.MyArray[ShowGroups.CurrentRow][4]="Blah">
        <CFSET variables.MyArray[ShowGroups.CurrentRow][5]="BLAH">
</cfloop>
<!--- convert the 2d array to a client variable for persistent storage --->
<cfwddx 
        action="CFML2WDDX" 
        input="#variables.MyArray#" 
        output="client.MyArray">
<!--- spit it right back out again just for giggles --->
<cfwddx 
        action="WDDX2CFML" 
        input="#client.MyArray#" 
        output="variables.MyArray">
<cfoutput>
<!---dump the raw wddx output --->
#client.MyArray#
<!--- 
display the 'query' which is actually output from a 
wddx-converted persistent client variable
--->
<table border="1">
<cfloop 
        from="1" 
        to="#ArrayLen(variables.MyArray)#" 
        index="ArrayRows">
        <tr>
        <cfloop 
                from="1" 
                to="#ArrayLen(variables.MyArray[1])#" 
                index="ArrayCols">
                <td>
                <cfif not Compare(ArrayCols,"2")>
                        <A 
href="mypage.cfm?ID=#variables.MyArray[ArrayRows][ArrayCols-1]#">#variables.MyArray[ArrayRows][ArrayCols]#</A>
                <cfelse>
                        #variables.MyArray[ArrayRows][ArrayCols]#
                </cfif>
                </td>   
        </cfloop>       
        </tr>
</cfloop>
</table>
</cfoutput>


-- 
--mattRobertson--
Janitor, MSB Web Systems
mysecretbase.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:200165
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