I am curious about the code below ... is there a BETTER way to call this with CFOBJECt and if so, why?
 
Once I build the struct "customer" I am going to stick it into a session named customer.
 
I am using CFINVOKE This way:
 
<!--- CFM Template --->
<cfinvoke
     component="customerController"
     method="getCustomer"
     returnvariable="customer">
     <cfinvokeargument name="customerID" value="#checkCustomer.customerID#">
</cfinvoke>
 
<!--- customerController.cfc --->
 
<cfcomponent displayname="customer" hint="Controls all access to customer information add, edit, delete.">
 <cffunction name="getCustomer" output="false" returntype="struct" displayname="Selects Customer" hint="Gets customer information and populates cthe customer structure.">
  <cfquery datasource="qdc2" name="checkCustomer">
   SELECT customerID, firstName, lastName, email, company, address1, address2,
     city, state, country, zip, dayPhone, evePhone, mailList
   FROM customer
   WHERE customerID = <cfqueryparam value="#arguments.customerID#" cfsqltype="CF_SQL_INTEGER">
  </cfquery>
   
  <cfif checkCustomer.recordcount>
   <cfset customer = StructNew()>
   <cfset customer.customerID = checkCustomer.customerID>
   <cfset customer.firstName = checkCustomer.firstName>
   <cfset customer.lastName = checkCustomer.lastName>
   <cfset customer.company = checkCustomer.company>
   <cfset customer.email = checkCustomer.email>
   <cfset customer.address1 = checkCustomer.address1>
   <cfset customer.address2 = checkCustomer.address2>
   <cfset customer.city = checkCustomer.city>
   <cfset customer.state = checkCustomer.state>
   <cfset customer.zip = checkCustomer.zip>
   <cfset customer.country = checkCustomer.country>
   <cfset customer.dayPhone = checkCustomer.dayPhone>
   <cfset customer.evePhone = checkCustomer.evePhone>
   <cfset customer.mailList = checkCustomer.mailList>
   
   <!--- Insert Shipping Information --->  
   <cfset customer.shipFirstName = "">
   <cfset customer.shipLastName = "">
   <cfset customer.shipCompany = "">
   <cfset customer.shipAddress1 = "">
   <cfset customer.shipAddress2 = "">
   <cfset customer.shipCity = "">
   <cfset customer.shipState = "">
   <cfset customer.shipZip = "">
   <cfset customer.shipCountry = "">
   <cfset customer.shipDayPhone = "">
  <cfelse>
   <!--- Do something else --->
  </cfif>
  <cfreturn customer>
 </cffunction>
</cfcomponent>

Reply via email to