[Zope] Returning incremented id from mysql query?

Ed Leafe ed@leafe.com
Thu, 15 Aug 2002 11:10:58 -0400


On Thursday, August 15, 2002, at 10:22  AM, Alec Munro wrote:

> Hmm, just did some reading on last_insert_id, and it says that it works
> on a per-connection basis.
> How are Zope's connections handled? Is it simply one connection that
> various SQL scripts can use when they need it? How about if a single SQL
> method contained multiple statements? Will these statements all be fed
> into the connection at once, or is there a possibility of another
> statement from another file sneaking in between two of them.

	I don't know the guts of what goes on in Zope, but AFAIK this is 
the only way to get the ID of a newly-inserted record. I've been using 
it for years now without a problem, and this is how every source I've 
ever read says to do it. And yes, a Zope process will use a single 
connection, and other processes won't interfere with the value returned 
by last_insert_id(), as it is connection-specific. And as far as 
multiple inserts from the same Zope instance, well, I can't imagine that 
they could use the same connection at the same time; there must be some 
sort of internal queueing going on there.

      ___/
     /
    __/
   /
  ____/
  Ed Leafe
  http://leafe.com/
  http://foxcentral.net