|
Revision 809, 1.1 kB
(checked in by lmajano, 6 years ago)
|
|
Illidium Scaffolding Templates
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | <%cffunction name="queryRowToStruct" access="private" output="false" returntype="struct"%> |
|---|
| 2 | <%cfargument name="qry" type="query" required="true"%> |
|---|
| 3 | |
|---|
| 4 | <%cfscript%> |
|---|
| 5 | /** |
|---|
| 6 | * Makes a row of a query into a structure. |
|---|
| 7 | * |
|---|
| 8 | * @param query The query to work with. |
|---|
| 9 | * @param row Row number to check. Defaults to row 1. |
|---|
| 10 | * @return Returns a structure. |
|---|
| 11 | * @author Nathan Dintenfass (nathan@changemedia.com) |
|---|
| 12 | * @version 1, December 11, 2001 |
|---|
| 13 | */ |
|---|
| 14 | //by default, do this to the first row of the query |
|---|
| 15 | var row = 1; |
|---|
| 16 | //a var for looping |
|---|
| 17 | var ii = 1; |
|---|
| 18 | //the cols to loop over |
|---|
| 19 | var cols = listToArray(qry.columnList); |
|---|
| 20 | //the struct to return |
|---|
| 21 | var stReturn = structnew(); |
|---|
| 22 | //if there is a second argument, use that for the row number |
|---|
| 23 | if(arrayLen(arguments) GT 1) |
|---|
| 24 | row = arguments[2]; |
|---|
| 25 | //loop over the cols and build the struct from the query row |
|---|
| 26 | for(ii = 1; ii lte arraylen(cols); ii = ii + 1){ |
|---|
| 27 | stReturn[cols[ii]] = qry[cols[ii]][row]; |
|---|
| 28 | } |
|---|
| 29 | //return the struct |
|---|
| 30 | return stReturn; |
|---|
| 31 | <%/cfscript%> |
|---|
| 32 | <%/cffunction%> |
|---|