<cffunction name="mysql_insert_id()">
  <cfset var get = "" />
  <cfquery datasource="#variables.my.dsn#" name="get">
    SELECT LAST_INSERT_ID() AS id
  </cfquery>
  <cfreturn get.id />
</cffunction>

You'll want to call this function from within a transaction with your
other queries to ensure it gives you the right result.  PHP doesn't
have this requirement, because in PHP you manage your own connections,
but in CF they are managed in a pool by CF itself.

cheers,
barneyb

On 6/6/05, Bob Flynn <[EMAIL PROTECTED]> wrote:
> This function returns the last inserted ID in MySQL. I have read the threads 
> about getting it from MS SQL, but that is done in the SQL. Is there a way to 
> do it for MySQL with CFML?
> 
> Thanks,
> 
> Bob
> 
-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 50 invites.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:208744
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to