List:General Discussion« Previous MessageNext Message »
From:mel list_php Date:February 15 2005 1:40pm
Subject:Re: last_insert_id
View as plain text  
really sorry to bother you with my connections problems.....
I've made a test using select connection_id(), to see what was the current 
identifier for my connection.
Each time I change of page, the connection_id is different, I suppose that 
is because I require my connection file at the beginning of each script.

This seems fine to me as I don't want to lock the tables, and the 
last_insert_id is performed in the same file than the insert, so on the per 
connection basis it's perfect (thank you very much for your help!!).

But it seems a bit strange to me to open so many connections. I know there 
is a limit somewhere, at the moment it is not a problem I don't have a lot 
of users and they are not coming often, but can it become one in the future?

I tried to find in the documentation some information on when is a 
connection open or if it is possible to keep one connection per user, but 
found nothing.

In addition I don't think it is possible because for the mysql server only 
one user gets connected, it doesn't care about the users I have in my 
authentication table.

If I misunderstood something please point me to some doc or give me some 
advice...



>From: Philippe Poelvoorde <philippe@stripped>
>Reply-To: "'mysql@stripped '" <mysql@stripped>
>To: mel list_php <list_php@stripped>
>CC: mysql@stripped
>Subject: Re: last_insert_id
>Date: Tue, 15 Feb 2005 10:50:40 +0000
>
>mel list_php wrote:
>>Hi!
>>
>>I have a database where several users can connect and input data.
>>
>>I managed to have my insert queries as atomic, but I was wondering about 
>>one special case: I make one insert, and retrieve the last id inserted by 
>>mysql because I need to update an other table with that id.
>>
>>- if one user inserts and retrieves the id, but between both one other has 
>>inserted something the id returned will be the right one?
>
>Last_insert_id() is consistent on a per-connection basis, meaning you don't 
>need to use lock (hopefullly !)
>http://dev.mysql.com/doc/mysql/en/getting-unique-id.html
>
>btw, what do you mean by : "I managed to have my insert queries as atomic". 
>Because if you do : INSERT .... it's already suppose to be atomic.
>
>HIMH.
>
>--
>Philippe Poelvoorde
>COS Trading Ltd.

_________________________________________________________________
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo

Thread
last_insert_idmel list_php15 Feb
  • Re: last_insert_idJohan Höök15 Feb
  • Re: last_insert_idAlec.Cawley15 Feb
  • Re: last_insert_idPhilippe Poelvoorde15 Feb
    • Re: last_insert_idmel list_php15 Feb
    • Re: last_insert_idmel list_php15 Feb
    • Re: last_insert_idmel list_php15 Feb