Description

This function returns a struct that has all the columns as keys and their corresponding values.

Returns

Struct

Category

Syntax

QueryGetRow(query, rowNumber)

History

Introduced in ColdFusion 11.

Parameters

Parameter Description
query The query object to get data from.
rowNumber The position of the row.

Example

<cfscript>
       myQuery=QueryNew("ID,Name,Rating","integer,varchar,double");
       myFirstData=StructNew();
       myFirstData={ID=1,Name="Nixon",Rating=56.87};
       QueryAddRow(myQuery,myFirstData);
       WriteOutput("Recordset updated with struct data:");
       WriteDump(myQuery);
       myGet=QueryGetRow(myQuery,1);
       WriteOutput("Returns struct with columns as keys:");
       WriteDump(myGet);
       //Try to return struct values for row=2 that does not exist
       try{
             QueryGetRow(myQuery,2);
       }
       catch(any q){
             WriteOutput(q.message);// Displays appropriate message
       }
</cfscript>

Output

Using member function

<cfscript>
       myQuery=QueryNew("ID,Name,Rating","integer,varchar,double");
       myFirstData=StructNew();
       myFirstData={ID=1,Name="Nixon",Rating=56.87};
       QueryAddRow(myQuery,myFirstData);
       myRow=myQuery.getRow(1);
       WriteDump(myQuery);
</cfscript>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy