CFLib.org – Common Function Library Project

queryGetRow(qry, row)

Last updated February 14, 2009

Version: 0 | Requires: ColdFusion MX | Library: DataManipulationLib

 
Rated 1 time(s). Average Rating: 5.0

Description:
Given a numeric row id, this function will return the single row as a query object.

Return Values:
Returns a query.

Example:

view plain print about
<cfset myQuery = QueryNew("Name, Time, Advanced""VarChar, Time, Bit")>
<cfset newRow = QueryAddRow(MyQuery, 2)>
<cfset QuerySetCell(myQuery, "Name""The Wonderful World of CMFL", 1)>
<cfset QuerySetCell(myQuery, "Time""9:15 AM", 1)>
<cfset QuerySetCell(myQuery, "Advanced", False, 1)>
<cfset QuerySetCell(myQuery, "Name""CFCs for Enterprise Applications", 2)>
<cfset QuerySetCell(myQuery, "Time""12:15 PM", 2)>
<cfset QuerySetCell(myQuery, "Advanced", True, 2)>

The second row of the query is: <cfdump var="#queryGetRow(myQuery,2)#">

Parameters:

Name Description Required
qry Query to inspect. Yes
row Numeric row to retrieve. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Return a single row from a query.
 * 
 * @param qry      Query to inspect. (Required)
 * @param row      Numeric row to retrieve. (Required)
 * @return Returns a query. 
 * @author Tony Felice (tfelice@reddoor.biz) 
 * @version 0, February 14, 2009 
 */

function queryGetRow(qry,row){
    var result = queryNew('');
    var cols = listToArray(arguments.qry.columnList);
    var i = '';

    for(i=1; i lte arrayLen(cols); i=i+1){
        queryAddColumn(result, cols[i], listToArray(arguments.qry[cols[i]][arguments.row]));
    }

    return result;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Adam Cameron Adam Cameron added
savecontent
24 day(s) ago

Pete Ruckelshaus Pete Ruckelshaus added
firstDayOfWeek
a while ago

Chris Weller Chris Weller added
convertQueryStri...
a while ago

Dan Bracuk Dan Bracuk added
getExcelPercenti...
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 42 time(s)

Barney Boisvert indentXml
Rated 5.0, 12 time(s)

Rachel Lehman deAccent
Rated 5.0, 8 time(s)

Markus Schneebeli                                 ListRemoveByStri...
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson