Hi,

Thank you to everyone on house of fusion who has been very helpful so far with 
my stupid questions. I have another ;)
 
I was looking at some code I generated for a gateway by Illudium PU36. The read 
and update functions do not make any sense in that it does not have any return 
for me to get! However I noticed a function called "queryRowToStruct" I am 
assuming this has something to do with how I can return the query or access the 
query from my service layer, however this is a private function so my service 
layer cannot access it if this was true. I am just confused because without a 
way to return the query whats the point in these functions?

Are they wrong, or should I give them a return? or I am missing the purpose?

Thanks Glyn

-------------------------------------------------------------------------

<!---Read--->
<cffunction name="readAdminUsers" access="public" output="false" 
returntype="void">
  <cfargument name="adminusers" type="salesMaxx.model.objects.adminusers" 
required="true" />
  <cfset var qRead = "" />
  <cfset var strReturn = structNew() />
  <cftry>
    <cfquery name="qRead" datasource="#variables.dsnBean.getname()#" 
username="#variables.dsnBean.getusername()#" 
password="#variables.dsnBean.getpassword()#">

                                SELECT

                                        adminId,

                                        firstname,

                                        surname,

                                        email,

                                        username,

                                        password,

                                        role,

                                        lastLogin,

                                        flag,

                                        IP,

                                        userLog,

                                        createddatetime

                                FROM    adminusers

                                WHERE   adminId = <cfqueryparam 
value="#arguments.adminusers.getadminId()#" CFSQLType="cf_sql_integer" />

                        </cfquery>
    <cfcatch type="database">
      <!--- leave the bean as is and set an empty query for the conditional 
logic below --->
      <cfset qRead = queryNew("id") />
    </cfcatch>
  </cftry>
  <cfif qRead.recordCount>
    <cfset strReturn = queryRowToStruct(qRead)>
    <cfset arguments.adminusers.init(argumentCollection=strReturn)>
  </cfif>
</cffunction>




<cffunction name="queryRowToStruct" access="private" output="false" 
returntype="struct">

                <cfargument name="qry" type="query" required="true">

                

                <cfscript>

                        /**

                         * Makes a row of a query into a structure.

                         * 

                         * @param query          The query to work with. 

                         * @param row    Row number to check. Defaults to row 
1. 

                         * @return Returns a structure. 

                         * @author Nathan Dintenfass ([email protected]) 

                         * @version 1, December 11, 2001 

                         */

                        //by default, do this to the first row of the query

                        var row = 1;

                        //a var for looping

                        var ii = 1;

                        //the cols to loop over

                        var cols = listToArray(qry.columnList);

                        //the struct to return

                        var stReturn = structnew();

                        //if there is a second argument, use that for the row 
number

                        if(arrayLen(arguments) GT 1)

                                row = arguments[2];

                        //loop over the cols and build the struct from the 
query row

                        for(ii = 1; ii lte arraylen(cols); ii = ii + 1){

                                stReturn[cols[ii]] = qry[cols[ii]][row];

                        }               

                        //return the struct

                        return stReturn;

                </cfscript>

        </cffunction>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:325484
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to