Ερώτηση για mysql - php

Alexandros Kosiaris alex at noc.grnet.gr
Thu Dec 17 10:50:36 EET 2009


rouvas at di.uoa.gr wrote:
> Christos Ricudis wrote:
>>> An i MySQL ('h opoiadipote alli multi-user basi) eixe tetoia problimata,
>>> den tha eixe kai megali anagnorisi, de nomizeis;
>>>
>>>
>>
>> Koimasai poly syxna m'ayto to pleyro?
> 
> Eidika gia tin MySQL oxi, alla genikos nai:-)
> 
> Sto sigkekrimeno zitima, pantos, (last insert id) de nomizo oti i MySQL
> exei lathos, dedomenou oti to epistrefomeno ID eksartatai apo to
> connection... nomizo.
Καλημέρες,

Να μην νομίζεις. Είναι σίγουρο. :-)

Από το
http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id

The ID that was generated is maintained in the server on a
per-connection basis. This means that the value returned by the function
to a given client is the first AUTO_INCREMENT value generated for most
recent statement affecting an AUTO_INCREMENT column by that client. This
value cannot be affected by other clients, even if they generate
AUTO_INCREMENT values of their own. This behavior ensures that each
client can retrieve its own ID without concern for the activity of other
clients, and without the need for locks or transactions.

Κατά τα άλλα επειδή όπως ήδη ειπώθηκε κάλλιστα μπορείς να καταλήξεις σε
κάποιο connection pooling σενάριο κάποια στιγμή, και επειδή όταν θα
συμβεί αυτό θα ξεχάσεις ότι το LAST_INSERT_ID() είναι
connection-dependent και τότε θα σε δαγκώσει καλύτερα να χρησιμοποιείς
transactions(και προφανώς τα αντίστοιχα table types)


-- 
Alexandros Kosiaris 	Network Operation Center , GRNET S.A.
e-mail : alex at noc.grnet.gr
Public Key Fingerprint :
D6B1 0634 BE65 719C 6C95  7492 8201 4B46 C478 F074


More information about the Linux-greek-users mailing list