query application structure onSessionEnd
In the onSessionEnd function in application.cfc, I want to read the SessionTimeout value from the application structure. I've tried this: cfargument name=ApplicationScope required=true and then review the cfdump of that structure, but I don't see sessiontimeout. Any thoughts? ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250714 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: query application structure onSessionEnd
The sessiontimeout value doesn't exist in the application structure. If you set the value in the This scope, try getting it like that. That should work. On 8/23/06, Brian Burkett [EMAIL PROTECTED] wrote: In the onSessionEnd function in application.cfc, I want to read the SessionTimeout value from the application structure. I've tried this: cfargument name=ApplicationScope required=true and then review the cfdump of that structure, but I don't see sessiontimeout. Any thoughts? ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250715 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: query application structure onSessionEnd
Thanks Ray, that works perfectly. The sessiontimeout value doesn't exist in the application structure. If you set the value in the This scope, try getting it like that. That should work. On 8/23/06, Brian Burkett [EMAIL PROTECTED] wrote: In the onSessionEnd function in application.cfc, I want to read the SessionTimeout value from the application structure. I've tried this: cfargument name=ApplicationScope required=true and then review the cfdump of that structure, but I don't see sessiontimeout. Any thoughts? ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250725 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Copy record from query into structure
Is there a way to copy an entire record from a query into a structure. I can reference the query like query[rowname][rownumber] but when you try to reference it as query[rownumber] it errors out. Bob ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215207 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=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Copy record from query into structure
I think you will have to make it into an Array of Structs rather than a Struct itself. Where each Array node is an equivalent row number. -Original Message- From: Robert Everland III [mailto:[EMAIL PROTECTED] Sent: 16 August 2005 15:27 To: CF-Talk Subject: Copy record from query into structure Is there a way to copy an entire record from a query into a structure. I can reference the query like query[rowname][rownumber] but when you try to reference it as query[rownumber] it errors out. Bob ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215220 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=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: Copy record from query into structure
cffunction name=RowToStruct cfargument name=qry cfargument name=rownumber cfscript var i = 0; var retval = structnew(); for(i=1;i lte listlen(arguments.qry.columnlist);i=i+1){ retval[LCase(listgetat(arguments.qry.columnlist,i))] = arguments.qry[listgetat(arguments.qry.columnlist,i)][arguments.rownumber]; } /cfscript cfreturn retval /cffunction -Original Message- From: Robertson-Ravo, Neil (RX) [mailto:[EMAIL PROTECTED] Sent: 16 August 2005 16:01 To: CF-Talk Subject: RE: Copy record from query into structure I think you will have to make it into an Array of Structs rather than a Struct itself. Where each Array node is an equivalent row number. -Original Message- From: Robert Everland III [mailto:[EMAIL PROTECTED] Sent: 16 August 2005 15:27 To: CF-Talk Subject: Copy record from query into structure Is there a way to copy an entire record from a query into a structure. I can reference the query like query[rowname][rownumber] but when you try to reference it as query[rownumber] it errors out. Bob ~| 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:215224 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=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: Copy record from query into structure
I wrote a little QueryTool cfc that does stuff like this a while back, feel free to use/abuse it: http://clearsoftware.net/client/queryTool.cfm -Joe On 8/16/05, Robert Everland III [EMAIL PROTECTED] wrote: Is there a way to copy an entire record from a query into a structure. I can reference the query like query[rowname][rownumber] but when you try to reference it as query[rownumber] it errors out. Bob ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215226 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
Re: Copy record from query into structure
Try this function from cflib.org http://www.cflib.org/udf.cfm?ID=358 On 8/16/05, Robert Everland III [EMAIL PROTECTED] wrote: Is there a way to copy an entire record from a query into a structure. I can reference the query like query[rowname][rownumber] but when you try to reference it as query[rownumber] it errors out. Bob ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215229 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
Nest query inside structure in CFMX web service?
I found a solution, though I admit I'm not totally happy with it. I can serialize a query into WDDX, then add it to my structure that is returned by the web service. On the other side, I can pick up that WDDX object, and de-serialize it back into a CF query object. That seems to work, but I worry about performance issues, and I don't really like the fact that the de-serializing step is required on the other end. It makes my data a little harder to understand out of the box. I would like to nest a query object inside of a structure that is returned by a web service I'm building. The web service is to be consumed by CFMX. I thought I had it working at one point, but now I get an ugly error that says the QueryBean cannot be deserialized. So, now I'm wondering if I imagined my initial success. Is what I want to do legal? Thanks in advance, Ben Mueller ~| 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:207649 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=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Nest query inside structure in CFMX web service?
I would like to nest a query object inside of a structure that is returned by a web service I'm building. The web service is to be consumed by CFMX. I thought I had it working at one point, but now I get an ugly error that says the QueryBean cannot be deserialized. So, now I'm wondering if I imagined my initial success. Is what I want to do legal? Thanks in advance, Ben Mueller ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207594 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=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Query vs. structure
In a web service, I've heard that there are issues with returning a CF query to a language other than CF.Is there any kind of a function to convert a query directly to a structure without having to loop over it and manually transfer it?Any insight on the whole returning of variables from a web service would be appreciated as well. John [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Query vs. structure
On Wed, 2004-03-10 at 11:51, Burns, John wrote: In a web service, I've heard that there are issues with returning a CF query to a language other than CF.Is there any kind of a function to convert a query directly to a structure without having to loop over it and manually transfer it?Any insight on the whole returning of variables from a web service would be appreciated as well. I have a custom tag that turns a query into xml http://www.rohanclan.com/index.cfm?mode=productproduct=cfxtoxml It's not free, but there is more then likely something similar out there if you need a free solution. -- Rob [EMAIL PROTECTED] [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Query vs. structure
QueryToStructOfArrays http://www.cflib.org/udf.cfm/QueryToStructOfArrays QueryToStructOfStructures http://www.cflib.org/udf.cfm/QueryToStructOfStructures QueryToArrayOfStructures http://www.cflib.org/udf.cfm/QueryToArrayOfStructures QueryToCSV http://www.cflib.org/udf.cfm/QueryToCSV QueryToVars http://www.cflib.org/udf.cfm/QueryToVars QueryToXML http://www.cflib.org/udf.cfm/QueryToXML Although I encourage you to try the Query method. I know some bugs got worked out in the 6.1 release. -nathan strutz -Original Message- From: Burns, John [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 10, 2004 12:52 PM To: CF-Talk Subject: Query vs. structure In a web service, I've heard that there are issues with returning a CF query to a language other than CF.Is there any kind of a function to convert a query directly to a structure without having to loop over it and manually transfer it?Any insight on the whole returning of variables from a web service would be appreciated as well. John [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Query vs. structure
On Wed, 2004-03-10 at 12:09, Nathan Strutz wrote: QueryToXML http://www.cflib.org/udf.cfm/QueryToXML does this tag supress the ?xml ... ? part when you do toString(xmlDoc)? That was killing me when trying to pass stuff around, and build complex xml documents where the query is just one part of the doc. -- Rob [EMAIL PROTECTED] [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Query vs. structure
If you are going to the XML route, might as well use WDDX. -Adam -Original Message- From: Nathan Strutz [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 10, 2004 08:09 PM To: 'CF-Talk' Subject: RE: Query vs. structure QueryToStructOfArrays http://www.cflib.org/udf.cfm/QueryToStructOfArrays QueryToStructOfStructures http://www.cflib.org/udf.cfm/QueryToStructOfStructures QueryToArrayOfStructures http://www.cflib.org/udf.cfm/QueryToArrayOfStructures QueryToCSV http://www.cflib.org/udf.cfm/QueryToCSV QueryToVars http://www.cflib.org/udf.cfm/QueryToVars QueryToXML http://www.cflib.org/udf.cfm/QueryToXML Although I encourage you to try the Query method. I know some bugs got worked out in the 6.1 release. -nathan strutz -Original Message- From: Burns, John [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 10, 2004 12:52 PM To: CF-Talk Subject: Query vs. structure In a web service, I've heard that there are issues with returning a CF query to a language other than CF.Is there any kind of a function to convert a query directly to a structure without having to loop over it and manually transfer it?Any insight on the whole returning of variables from a web service would be appreciated as well. John [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Query to structure
Hello I have a query which returns one row with a lot of columns... I want to take the query and convert it to a structure, with the key being the column name and the value being the value of the column... How do you do this? Ryan [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Query to structure
You could try something like... CFQUERY NAME=qry... /CFQUERY CFSET strQuery = StructNew() CFLOOP LIST=#qry.ColumnList# INDEX=idxColumn CFSET strQuery[idxColumn] = qry[idxColumn][1] /CFLOOP CFDUMP VAR=#strQuery# HTH -Original Message- From: Ryan Mitchell [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 19, 2003 12:42 To: CF-Talk Subject: Query to structure Hello I have a query which returns one row with a lot of columns... I want to take the query and convert it to a structure, with the key being the column name and the value being the value of the column... How do you do this? Ryan _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Query to structure
Ryan, I want to take the query and convert it to a structure, with the key being the column name and the value being the value of the column... Simply loop over the column list: cfset mystruct = structnew() cfloop list=#myquery.columnList# index=col cfset mystruct[col] = myquery[col] /cfloop Tim. --- RAWNET LTD - Internet, New Media and ebusiness Gurus. Visit our new website at http://www.rawnet.com for more information about our company, or call us free anytime on 0800 294 24 24. --- Tim Blair Web Application Engineer, Rawnet Limited Direct Phone : +44 (0) 1344 393 441 Switchboard : +44 (0) 1344 393 040 --- This message may contain information which is legally privileged and/or confidential.If you are not the intended recipient, you are hereby notified that any unauthorised disclosure, copying, distribution or use of this information is strictly prohibited. Such notification notwithstanding, any comments, opinions, information or conclusions expressed in this message are those of the originator, not of rawnet limited, unless otherwise explicitly and independently indicated by an authorised representative of rawnet limited. --- [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Query to structure
Thanks :) On 19/11/03 12:51 pm, Tim Blair [EMAIL PROTECTED] wrote: Ryan, I want to take the query and convert it to a structure, with the key being the column name and the value being the value of the column... Simply loop over the column list: cfset mystruct = structnew() cfloop list=#myquery.columnList# index=col cfset mystruct[col] = myquery[col] /cfloop Tim. --- RAWNET LTD - Internet, New Media and ebusiness Gurus. Visit our new website at http://www.rawnet.com for more information about our company, or call us free anytime on 0800 294 24 24. --- Tim Blair Web Application Engineer, Rawnet Limited Direct Phone : +44 (0) 1344 393 441 Switchboard : +44 (0) 1344 393 040 --- This message may contain information which is legally privileged and/or confidential.If you are not the intended recipient, you are hereby notified that any unauthorised disclosure, copying, distribution or use of this information is strictly prohibited. Such notification notwithstanding, any comments, opinions, information or conclusions expressed in this message are those of the originator, not of rawnet limited, unless otherwise explicitly and independently indicated by an authorised representative of rawnet limited. --- [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Query to structure
There's also a UDF on cflib.org that does this. -d - Original Message - From: Ryan Mitchell [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Wednesday, November 19, 2003 7:14 AM Subject: Re: Query to structure Thanks :) On 19/11/03 12:51 pm, Tim Blair [EMAIL PROTECTED] wrote: Ryan, I want to take the query and convert it to a structure, with the key being the column name and the value being the value of the column... Simply loop over the column list: cfset mystruct = structnew() cfloop list=#myquery.columnList# index=col cfset mystruct[col] = myquery[col] /cfloop Tim. --- RAWNET LTD - Internet, New Media and ebusiness Gurus. Visit our new website at http://www.rawnet.com for more information about our company, or call us free anytime on 0800 294 24 24. --- Tim Blair Web Application Engineer, Rawnet Limited Direct Phone : +44 (0) 1344 393 441 Switchboard : +44 (0) 1344 393 040 --- This message may contain information which is legally privileged and/or confidential.If you are not the intended recipient, you are hereby notified that any unauthorised disclosure, copying, distribution or use of this information is strictly prohibited. Such notification notwithstanding, any comments, opinions, information or conclusions expressed in this message are those of the originator, not of rawnet limited, unless otherwise explicitly and independently indicated by an authorised representative of rawnet limited. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Query to Structure with keys...
Hey its Brainfart Wednesday. Everyday lately seems to be a brainfart. I have this query... cfquery name=getProductDetails datasource=XXX SELECT PartNumber, ProductTitle FROM Products P WHEREProduct_ID IN (9909,9910,9911,9912,9913,9914,9371,9372,9378,9380,9855,8081,9631) /cfquery I would to place this query into a structure. The keys need to come from the Product_IDs in the where clause of the query. Each key has as its value, the column names that are returned. Any ideas on how to do this??? cfscript based code samples would be appreciated. Ché Vilnonis Application Developer Advertising Systems Incorporated 8470C Remington Avenue Pennsauken, NJ 08110 p: 856.488.2211 f: 856.488.1990 www.asitv.com ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm
RE: Query to Structure with keys...
First of all, if you want to use the Product ID's you need to return them with the Select Clause. Just using a field in the where clause does not return them. cfquery name=getProductDetails datasource=XXX SELECT Product_ID, PartNumber, ProductTitle FROM Products P WHEREProduct_ID IN (9909,9910,9911,9912,9913,9914,9371,9372,9378,9380,9855,8081,9631) /cfquery Then what I've done in the past is just loop over the query and create a structure. I'd love to know if there are any more direct ways to do this. cfscript productStruct = newStruct(); for (i=1;i=getProductDetails.recordcount;i=i+1) { tempArray = newArray(1); tempArray[1] = getProductDetails.PartNumber; tempArray[2] = getProductDetails.ProductTitle; productStruc[getProductDetails.Product_ID][i] = tempArray; } /cfscript Then you should be able to play with your new structure something like this. cfoutput tdPartNumber/tdtdProductTitle/td td#productStruct['9911'][1]#/tdtd#productStruct['9911'][2]#/td /cfoutput Please pardon in problem with my cfscript code. I just wrote that off the top of my head, and I don't use cfscript all that often. I hope this helps. Ian Skinner -Original Message- From: Che Vilnonis [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 11:13 AM To: CF-Talk Subject: Query to Structure with keys... Hey its Brainfart Wednesday. Everyday lately seems to be a brainfart. I have this query... cfquery name=getProductDetails datasource=XXX SELECT PartNumber, ProductTitle FROM Products P WHEREProduct_ID IN (9909,9910,9911,9912,9913,9914,9371,9372,9378,9380,9855,8081,9631) /cfquery I would to place this query into a structure. The keys need to come from the Product_IDs in the where clause of the query. Each key has as its value, the column names that are returned. Any ideas on how to do this??? cfscript based code samples would be appreciated. Ché Vilnonis Application Developer Advertising Systems Incorporated 8470C Remington Avenue Pennsauken, NJ 08110 p: 856.488.2211 f: 856.488.1990 www.asitv.com ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
RE: Query to Structure with keys...
you could use the valuelist(query.colname) function to do this with out the loop -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 3:13 PM To: CF-Talk Subject: RE: Query to Structure with keys... First of all, if you want to use the Product ID's you need to return them with the Select Clause. Just using a field in the where clause does not return them. cfquery name=getProductDetails datasource=XXX SELECT Product_ID, PartNumber, ProductTitle FROM Products P WHEREProduct_ID IN (9909,9910,9911,9912,9913,9914,9371,9372,9378,9380,9855,8081,9631) /cfquery Then what I've done in the past is just loop over the query and create a structure. I'd love to know if there are any more direct ways to do this. cfscript productStruct = newStruct(); for (i=1;i=getProductDetails.recordcount;i=i+1) { tempArray = newArray(1); tempArray[1] = getProductDetails.PartNumber; tempArray[2] = getProductDetails.ProductTitle; productStruc[getProductDetails.Product_ID][i] = tempArray; } /cfscript Then you should be able to play with your new structure something like this. cfoutput tdPartNumber/tdtdProductTitle/td td#productStruct['9911'][1]#/tdtd#productStruct['9911'][2]#/td /cfoutput Please pardon in problem with my cfscript code. I just wrote that off the top of my head, and I don't use cfscript all that often. I hope this helps. Ian Skinner -Original Message- From: Che Vilnonis [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 11:13 AM To: CF-Talk Subject: Query to Structure with keys... Hey its Brainfart Wednesday. Everyday lately seems to be a brainfart. I have this query... cfquery name=getProductDetails datasource=XXX SELECT PartNumber, ProductTitle FROM Products P WHEREProduct_ID IN (9909,9910,9911,9912,9913,9914,9371,9372,9378,9380,9855,8081,9631) /cfquery I would to place this query into a structure. The keys need to come from the Product_IDs in the where clause of the query. Each key has as its value, the column names that are returned. Any ideas on how to do this??? cfscript based code samples would be appreciated. Ché Vilnonis Application Developer Advertising Systems Incorporated 8470C Remington Avenue Pennsauken, NJ 08110 p: 856.488.2211 f: 856.488.1990 www.asitv.com ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com
RE: Query to Structure with keys...
Code examples would be great!!! -Original Message- From: Matthew Friedman [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 3:24 PM To: CF-Talk Subject: RE: Query to Structure with keys... you could use the valuelist(query.colname) function to do this with out the loop -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 3:13 PM To: CF-Talk Subject: RE: Query to Structure with keys... First of all, if you want to use the Product ID's you need to return them with the Select Clause. Just using a field in the where clause does not return them. cfquery name=getProductDetails datasource=XXX SELECT Product_ID, PartNumber, ProductTitle FROM Products P WHEREProduct_ID IN (9909,9910,9911,9912,9913,9914,9371,9372,9378,9380,9855,8081,9631) /cfquery Then what I've done in the past is just loop over the query and create a structure. I'd love to know if there are any more direct ways to do this. cfscript productStruct = newStruct(); for (i=1;i=getProductDetails.recordcount;i=i+1) { tempArray = newArray(1); tempArray[1] = getProductDetails.PartNumber; tempArray[2] = getProductDetails.ProductTitle; productStruc[getProductDetails.Product_ID][i] = tempArray; } /cfscript Then you should be able to play with your new structure something like this. cfoutput tdPartNumber/tdtdProductTitle/td td#productStruct['9911'][1]#/tdtd#productStruct['9911'][2]#/td /cfoutput Please pardon in problem with my cfscript code. I just wrote that off the top of my head, and I don't use cfscript all that often. I hope this helps. Ian Skinner -Original Message- From: Che Vilnonis [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 11:13 AM To: CF-Talk Subject: Query to Structure with keys... Hey its Brainfart Wednesday. Everyday lately seems to be a brainfart. I have this query... cfquery name=getProductDetails datasource=XXX SELECT PartNumber, ProductTitle FROM Products P WHEREProduct_ID IN (9909,9910,9911,9912,9913,9914,9371,9372,9378,9380,9855,8081,9631) /cfquery I would to place this query into a structure. The keys need to come from the Product_IDs in the where clause of the query. Each key has as its value, the column names that are returned. Any ideas on how to do this??? cfscript based code samples would be appreciated. Ché Vilnonis Application Developer Advertising Systems Incorporated 8470C Remington Avenue Pennsauken, NJ 08110 p: 856.488.2211 f: 856.488.1990 www.asitv.com ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
RE: Query to Structure with keys...
If you are looking at moving a query to a structure there is a great UDF on cflib that I use all the time. Try this below (this is not my code!!!) and then put the output into a cfdump to see the outcome. For full documentation look at www.CFlib.org. cfscript /** * Converts a query object into a structure of structures accessible by its primary key. * * @param theQuery The query you want to convert to a structure of structures. * @param primaryKey Query column to use as the primary key. * @return Returns a structure. * @author Shawn Seley ([EMAIL PROTECTED]) * @version 1, March 27, 2002 */ 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); } /cfscript -Original Message- From: Che Vilnonis [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 3:20 PM To: CF-Talk Subject: RE: Query to Structure with keys... Code examples would be great!!! -Original Message- From: Matthew Friedman [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 3:24 PM To: CF-Talk Subject: RE: Query to Structure with keys... you could use the valuelist(query.colname) function to do this with out the loop -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 3:13 PM To: CF-Talk Subject: RE: Query to Structure with keys... First of all, if you want to use the Product ID's you need to return them with the Select Clause. Just using a field in the where clause does not return them. cfquery name=getProductDetails datasource=XXX SELECT Product_ID, PartNumber, ProductTitle FROM Products P WHEREProduct_ID IN (9909,9910,9911,9912,9913,9914,9371,9372,9378,9380,9855,8081,9631) /cfquery Then what I've done in the past is just loop over the query and create a structure. I'd love to know if there are any more direct ways to do this. cfscript productStruct = newStruct(); for (i=1;i=getProductDetails.recordcount;i=i+1) { tempArray = newArray(1); tempArray[1] = getProductDetails.PartNumber; tempArray[2] = getProductDetails.ProductTitle; productStruc[getProductDetails.Product_ID][i] = tempArray; } /cfscript Then you should be able to play with your new structure something like this. cfoutput tdPartNumber/tdtdProductTitle/td td#productStruct['9911'][1]#/tdtd#productStruct['9911'][2]#/td /cfoutput Please pardon in problem with my cfscript code. I just wrote that off the top of my head, and I don't use cfscript all that often. I hope this helps. Ian Skinner -Original Message- From: Che Vilnonis [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 11:13 AM To: CF-Talk Subject: Query to Structure with keys... Hey its Brainfart Wednesday. Everyday lately seems to be a brainfart. I have this query... cfquery name=getProductDetails datasource=XXX SELECT PartNumber, ProductTitle FROM Products P WHEREProduct_ID IN (9909,9910,9911,9912,9913,9914,9371,9372,9378,9380,9855,8081,9631) /cfquery I would to place this query into a structure. The keys need to come from the Product_IDs in the where clause of the query. Each key has as its value, the column names that are returned. Any ideas on how to do this??? cfscript based code samples would be appreciated. Ché Vilnonis Application Developer Advertising Systems Incorporated 8470C Remington Avenue Pennsauken, NJ 08110 p: 856.488.2211 f: 856.488.1990 www.asitv.com ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
RE: Query to Structure with keys...
Thanks...you gotta love CFLIB.org! I can't believe I forgot about that resource. -Original Message- From: Matthew Friedman [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 3:37 PM To: CF-Talk Subject: RE: Query to Structure with keys... If you are looking at moving a query to a structure there is a great UDF on cflib that I use all the time. Try this below (this is not my code!!!) and then put the output into a cfdump to see the outcome. For full documentation look at www.CFlib.org. cfscript /** * Converts a query object into a structure of structures accessible by its primary key. * * @param theQuery The query you want to convert to a structure of structures. * @param primaryKey Query column to use as the primary key. * @return Returns a structure. * @author Shawn Seley ([EMAIL PROTECTED]) * @version 1, March 27, 2002 */ 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); } /cfscript -Original Message- From: Che Vilnonis [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 3:20 PM To: CF-Talk Subject: RE: Query to Structure with keys... Code examples would be great!!! -Original Message- From: Matthew Friedman [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 3:24 PM To: CF-Talk Subject: RE: Query to Structure with keys... you could use the valuelist(query.colname) function to do this with out the loop -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 3:13 PM To: CF-Talk Subject: RE: Query to Structure with keys... First of all, if you want to use the Product ID's you need to return them with the Select Clause. Just using a field in the where clause does not return them. cfquery name=getProductDetails datasource=XXX SELECT Product_ID, PartNumber, ProductTitle FROM Products P WHEREProduct_ID IN (9909,9910,9911,9912,9913,9914,9371,9372,9378,9380,9855,8081,9631) /cfquery Then what I've done in the past is just loop over the query and create a structure. I'd love to know if there are any more direct ways to do this. cfscript productStruct = newStruct(); for (i=1;i=getProductDetails.recordcount;i=i+1) { tempArray = newArray(1); tempArray[1] = getProductDetails.PartNumber; tempArray[2] = getProductDetails.ProductTitle; productStruc[getProductDetails.Product_ID][i] = tempArray; } /cfscript Then you should be able to play with your new structure something like this. cfoutput tdPartNumber/tdtdProductTitle/td td#productStruct['9911'][1]#/tdtd#productStruct['9911'][2]#/td /cfoutput Please pardon in problem with my cfscript code. I just wrote that off the top of my head, and I don't use cfscript all that often. I hope this helps. Ian Skinner -Original Message- From: Che Vilnonis [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 11, 2002 11:13 AM To: CF-Talk Subject: Query to Structure with keys... Hey its Brainfart Wednesday. Everyday lately seems to be a brainfart. I have this query... cfquery name=getProductDetails datasource=XXX SELECT PartNumber, ProductTitle FROM Products P WHEREProduct_ID IN (9909,9910,9911,9912,9913,9914,9371,9372,9378,9380,9855,8081,9631) /cfquery I would to place this query into a structure. The keys need to come from the Product_IDs in the where clause of the query. Each key has as its value, the column names that are returned. Any ideas on how to do this??? cfscript based code samples would be appreciated. Ché Vilnonis Application Developer Advertising Systems Incorporated 8470C Remington Avenue Pennsauken, NJ 08110 p: 856.488.2211 f: 856.488.1990 www.asitv.com ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
How to convert 1-record query to structure (EBW)
I'm selecting a single record from SQL Server and want to pass the results as a structured variable, rather than a query variable. How do I obtain the list of fields in the query so that I can loop through them? I know how to loop through a collection of fields in a structured variable and I know how to loop through a list of fields that I define, but I don't know how to obtain the list of fields in a query. Any tips would be great. Below are the examples I do know. Looping through query based on explicit list of fields CFSET FieldList = FirstName,LastName,UserName,PrimaryEmail cfloop collection=#qUserDetails# item=thisField CFSET UserDetails.#thisField# = Evaluate(qUserDetails.#thisField#) /cfloop Looping through collection: works for valid struct or COM object, but not for query object CFOutput cfloop collection=#UserRole# item=var UserRole.#var# = #UserRole[var]#br /cfloop /CFOutput ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Re: How to convert 1-record query to structure (EBW)
At 10:15 AM 11/24/2002 -0500, you wrote: I'm selecting a single record from SQL Server and want to pass the results as a structured variable, rather than a query variable. How do I obtain the list of fields in the query so that I can loop through them? queryname.columnlist will give you the list of fields, but I'm not sure why you would want to do this. First off, you do understand that you can access a query as a structure of arrays? If you want to access the 10th record of a query, you can do this: Queryname.Column[10] If you leave out the array index, the first row is automatically returned (Unless you are looping over the query, the current row is returned ) As far as this code: CFSET FieldList = FirstName,LastName,UserName,PrimaryEmail cfloop collection=#qUserDetails# item=thisField CFSET UserDetails.#thisField# = Evaluate(qUserDetails.#thisField#) /cfloop Looping through collection: works for valid struct or COM object, but not for query object CFOutput cfloop collection=#UserRole# item=var UserRole.#var# = #UserRole[var]#br /cfloop /CFOutput You can loop through a query, using either cfloop or cfoutput, both with the query attribute. And then you can use cfloop to loop over the column list. So all of the above code can be condensed into something like this: cfoutput query=MyQuery cfloop item=var list=#myQuery.columnlist# MyQuery.#var# = #MyQuery.var# /cfloop /cfoutput I don't know if I would recommend using dynamic columns, though. It is much better to handcode them. I have never run across a situation where I needed to dynamically generate query column names ( other than debugging, but for that I usually use cfdump ) Based on your past two questions, you seem to be missing general CF knowledge. I might recommend reading Developing ColdFusion MX Applications with CFML and Getting Started Building ColdFusion MX Applications. After that, you may want to flip through the CFML Reference. All are located here for free: http://livedocs.macromedia.com/cfmxdocs/dochome.jsp There is similar documents in the ColdFusion 5 Docs. If you want to buy a book, I can plug some of my own ( ColdFusion: A Beginner's Guide http://www.amazon.com/exec/obidos/ASIN/0072191090/instantcoldfu-20 or ColdFusion: The Complete Reference: http://www.amazon.com/exec/obidos/ASIN/0072225564/instantcoldfu-20 ) -- Jeffry Houser | mailto:[EMAIL PROTECTED] DotComIt, Putting you on the web AIM: Reboog711 | Phone: 1-203-379-0773 -- My CFMX Book: http://www.amazon.com/exec/obidos/ASIN/0072225564/instantcoldfu-20 My Books: http://www.instantcoldfusion.com My Band: http://www.farcryfly.com ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
RE: How to convert 1-record query to structure (EBW)
Jeffry, Thanks for the input. I usually work with the Query object when getting record sets, but when I'm creating new or editing existing records (e.g. user or event), the form will pass all these fields to target tag (actually to index.cfm using Fusebox architecture), which will then validate them and pass them to a model fuseaction, which will finally pass them to a StoredProc to insert/update the table. So, in this case I'm looking to pass just the UserDetails structure, instead of the 10+ fields that it contains. Hence, my apparently suboptimal desire to convert the 1-record query into a structure. Thanks for your input and advice. I do have have read CF WACK (Forta), Instant CF (yours) and CFML Reference, but will flip through them again for variations on passing numerous fields for processing. Thanks, Erik -Original Message- From: Jeffry Houser [mailto:[EMAIL PROTECTED]] Sent: Sunday, November 24, 2002 1:41 PM To: CF-Talk Subject: Re: How to convert 1-record query to structure (EBW) At 10:15 AM 11/24/2002 -0500, you wrote: I'm selecting a single record from SQL Server and want to pass the results as a structured variable, rather than a query variable. How do I obtain the list of fields in the query so that I can loop through them? queryname.columnlist will give you the list of fields, but I'm not sure why you would want to do this. First off, you do understand that you can access a query as a structure of arrays? If you want to access the 10th record of a query, you can do this: Queryname.Column[10] If you leave out the array index, the first row is automatically returned (Unless you are looping over the query, the current row is returned ) As far as this code: CFSET FieldList = FirstName,LastName,UserName,PrimaryEmail cfloop collection=#qUserDetails# item=thisField CFSET UserDetails.#thisField# = Evaluate(qUserDetails.#thisField#) /cfloop Looping through collection: works for valid struct or COM object, but not for query object CFOutput cfloop collection=#UserRole# item=var UserRole.#var# = #UserRole[var]#br /cfloop /CFOutput You can loop through a query, using either cfloop or cfoutput, both with the query attribute. And then you can use cfloop to loop over the column list. So all of the above code can be condensed into something like this: cfoutput query=MyQuery cfloop item=var list=#myQuery.columnlist# MyQuery.#var# = #MyQuery.var# /cfloop /cfoutput I don't know if I would recommend using dynamic columns, though. It is much better to handcode them. I have never run across a situation where I needed to dynamically generate query column names ( other than debugging, but for that I usually use cfdump ) Based on your past two questions, you seem to be missing general CF knowledge. I might recommend reading Developing ColdFusion MX Applications with CFML and Getting Started Building ColdFusion MX Applications. After that, you may want to flip through the CFML Reference. All are located here for free: http://livedocs.macromedia.com/cfmxdocs/dochome.jsp There is similar documents in the ColdFusion 5 Docs. If you want to buy a book, I can plug some of my own ( ColdFusion: A Beginner's Guide http://www.amazon.com/exec/obidos/ASIN/0072191090/instantcoldfu-20 or ColdFusion: The Complete Reference: http://www.amazon.com/exec/obidos/ASIN/0072225564/instantcoldfu-20 ) -- Jeffry Houser | mailto:[EMAIL PROTECTED] DotComIt, Putting you on the web AIM: Reboog711 | Phone: 1-203-379-0773 -- My CFMX Book: http://www.amazon.com/exec/obidos/ASIN/0072225564/instantcoldfu-20 My Books: http://www.instantcoldfusion.com My Band: http://www.farcryfly.com ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
RE: How to convert 1-record query to structure (EBW)
At 12:47 AM 11/25/2002 -0500, you wrote: Thanks for the input. I usually work with the Query object when getting record sets, but when I'm creating new or editing existing records (e.g. user or event), the form will pass all these fields to target tag (actually to index.cfm using Fusebox architecture), which will then validate them and pass them to a model fuseaction, which will finally pass them to a StoredProc to insert/update the table. So, in this case I'm looking to pass just the UserDetails structure, instead of the 10+ fields that it contains. Hence, my apparently suboptimal desire to convert the 1-record query into a structure. I did not understand that this is what you were trying to do from the original post. I bet writing a function to return a single row of a query might be good for these situations, because I can't think of a way off the top of my head to accomplish the task. I just looked. Here is the function: http://www.cflib.org/udf.cfm?ID=358 It looks as if it uses a method similar to what we discussed, except it is using CFScript. The function should work in both CF5 and CFMX. Thanks for your input and advice. I do have have read CF WACK (Forta), Instant CF (yours) and CFML Reference, but will flip through them again for variations on passing numerous fields for processing. ( Thanks for the support ) -- Jeffry Houser | mailto:[EMAIL PROTECTED] DotComIt, Putting you on the web AIM: Reboog711 | Phone: 1-203-379-0773 -- My CFMX Book: http://www.amazon.com/exec/obidos/ASIN/0072225564/instantcoldfu-20 My Books: http://www.instantcoldfusion.com My Band: http://www.farcryfly.com ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.