>Yes, returnType=struct would work if you want to return the values as a
>structure, but that seems kind of odd. Why would a method return
exactly
>what it was passed? Normally when I do an insert in a method, I return
the
>ID of the new record.

I see. I'm looking at Macromedia's NoteBoard Flash Remoting example for
ideas, and when an insert is done there, the returnType = struct because
the ID of the new record is returned as part of a structure which is
created by a query in another method. What you're saying is that rather
than using a structure, you normally run a query to get the new ID and
return that, thereby using a returnType of query, correct? Thanks for
helping me understand this. The relevant noteBoard code I'm studying is
below.

<cffunction name="addNote" access="remote" returntype="struct">
<cfargument name="note" type="string" required="true">
<cfargument name="title" type="string" required="true">
<cfset var rQuery = "" />

<cfquery datasource="#DATASOURCENAME#" name="rQuery">
INSERT INTO Notes (title, noteData) VALUES
('#arguments.title#','#arguments.note#')
</cfquery>
<cfquery datasource="#DATASOURCENAME#" name='rQuery'>
Select @@identity AS newId
</cfquery>

<cfreturn getNote(rQuery.newId)>
</cffunction>

<cffunction name="getNote" access="remote" returntype="struct">
<cfargument name="id" type="numeric" required="true">
<cfset var rQuery = "" />
<cfset var noteStruct = StructNew() />

<cfquery datasource="#DATASOURCENAME#" name="rQuery">
SELECT * FROM Notes where id = #arguments.id#
</cfquery>

<cfloop query="rQuery">
<cfset noteStruct.id = id />
<cfset noteStruct.title = title />
<cfset noteStruct.noteData = noteData />
</cfloop>


<cfreturn noteStruct>
</cffunction>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to