all groups > coldfusion flash integration > july 2006 >
You're in the

coldfusion flash integration

group:

I want to return an array instead of a query


I want to return an array instead of a query swickes
7/17/2006 4:49:45 PM
coldfusion flash integration:
Dear Forum,

My Flash program uses a web service connector that connects to a CFC.
Everything works well with "return type="query.

Now, I would like to add one more row of (calculated) data to the query
results. So I thought, let's output the query to an array, add the calculated
row, and have the web service return an array instead of a query.

The problem: no column names are delivered to Flash with "return type="array."
With return type="query," Flash received the column names from the web service
and used those in my datagrid.

Question: should I just use two web services (one with query info and one with
calculated data) or is there a way to return column names, query results, and
additional info all with one web service call?

Thanks in advance!

P.S. I see using CFDump that a query result is a "special kind" of array. Can
anyone explain how this works "behind the scenes?"
Re: I want to return an array instead of a query The ScareCrow
7/18/2006 12:10:13 AM
Why not just add the calculated row to the query ?

Re: I want to return an array instead of a query swickes
7/18/2006 1:46:20 PM
Ken,

Thanks for your suggestion. We can add a calculated row in some circumstances.
We also have the need to add additional info to the web service return variable
that we'd rather have ColdFusion add. For example, customized text to explain
an error.

So I'm still wondering:
1. How does a query result differ from a normal array?
2. Are there ways to have a single web service return an array and a string?

Thanks,
Steve
Re: I want to return an array instead of a query The ScareCrow
7/18/2006 11:16:32 PM
Steve,

1. How does a query result differ from a normal array?
Sorry, can't help here.

2. Are there ways to have a single web service return an array and a string?
Not as far as I know.
What I have done is in the case of an error, create an empty query.
I then set any error message to a session variable.
In the page that would display the query or error message, I ckeck if the
session variable is not empty and if so display the message. I then reset the
session variable to empty.

This also allows me to inform the user that an insert/update has been
performed while returning error codes from stored procedures.

Ken
Re: I want to return an array instead of a query Roks-1
8/1/2006 10:21:58 PM
Here us what I am doing.


<cffunction name="getMasterQuery" output="false" access="remote"
returntype="array">
<cfargument name="pageID" required="true">
<cfargument name="docID" required="true">
<cfparam name="Mode" default="safe2">
<cfparam name="Result" default="">
<cfquery name="qText" datasource="acSnap">
SELECT * FROM text
WHERE pageID = #arguments.pageID# and docID = #arguments.docID#;
</cfquery>
<cfset myarray=arraynew(2)>

<cfloop query="qText">
<cfset myarray[CurrentRow][1]=TextID>
<!--- <cfset myarray[CurrentRow][2]=pageName> --->
<cfset myarray[CurrentRow][2]=textValue>
<cfset myarray[CurrentRow][3]=textName>
</cfloop>

<cfreturn myarray>
</cffunction>


Hope this helps,

Rich
Re: I want to return an array instead of a query swickes
8/1/2006 10:40:01 PM
Thanks Rich,

I'm assuming you don't need your column names in the application that is
consuming this web service?? That is my only remaining question here; is there
some way to simulate a query result (including column names) in the array you
build and pass back?

Seems like Flash considers the returned data an array, whether ColdFusion is
passing back a query result or an array. But somehow, Flash recognizes that
column names are embedded, when the source of the array is a query result.

Any thoughts?
Steve

Re: I want to return an array instead of a query The ScareCrow
8/13/2006 12:00:00 AM
I would suggest looking at the flash remoting online docs.

I found the following which may help

http://livedocs.macromedia.com/flashremoting/mx/Using_Flash_Remoting_MX/asDict32.htm#106947

AddThis Social Bookmark Button