I'm having trouble passing LAST_INSERT_ID() from one function to another.  I'm 
new to CFC and not sure how this is done or if I have layout the cfc correctly 
with THIS.

<cfcomponent>
<cfset THIS.contactID = "">
<cfset THIS.firstName = "">
<cfset THIS.lastName = "">
        <cffunction name="addContact" access="public">
                <cftransaction>                 
                        <cfquery name="qaddContact" datasource="#dsn#">
                                INSERT INTO Contacts
                                                (firstName
                                                ,lastName                       
        
                                                )
                                                VALUES
                                                ('#(THIS.firstName)#'
                                                ,'#(THIS.lastName)#'
                                                )
                        </cfquery>                      
                        <cfquery name="lastRec" datasource="kroad">
                                SELECT LAST_INSERT_ID() as lastid
                        </cfquery>
                        
                        <cfset THIS.contactID = lastRec.lastid>
                        
                </cftransaction>
        </cffunction>
        
        <cffunction name="getLastContact" returntype="query" access="public">
                <cfquery name="qGetLastContact" datasource="#dsn#">
                        SELECT *
                        FROM contacts
                        WHERE contacts.contactID = #THIS.contactID#
                </cfquery>
                <cfreturn qGetLastContact>              
        </cffunction>
</cfcomponent>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:231816
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to