Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Created June 27, 2014 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevewithington/fe0dcd53b18b340f8ffa to your computer and use it in GitHub Desktop.
Save stevewithington/fe0dcd53b18b340f8ffa to your computer and use it in GitHub Desktop.
ColdFusion / CFML : get a query containing the desired row data.
<cfscript>
/**
* @param qry The query containing the desired data (required)
* @param row The desired row number (optional)
* @return Returns a query containing the desired row data
*/
public query function getQueryRow(required query qry, numeric row) {
var requestedRow = StructKeyExists(arguments, 'row') ? arguments.row : arguments.qry.currentrow;
var rs = QueryNew(arguments.qry.columnList);
QueryAddRow(rs);
for ( var col in ListToArray(arguments.qry.columnList) ) {
QuerySetCell(rs, col, arguments.qry[col][requestedRow]);
}
return rs;
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment