documentation: mysql_insert_id() thread safe w persistent connections?
| From: | André Langhorst | Date: | Wed, 06 Sep 2000 01:12:13 +0000 |
| Subject: | documentation: mysql_insert_id() thread safe w persistent connections? | ||
| Groups: | php.dev php.qa | ||
| Request: | Send a blank email to php-dev+get-32278@lists.php.net to get a copy of this message | ||
Have a look at these both explications from the manual page on "persistent connections" (or read summary below each).
1)
execution of your script ends. When a persistent connection is requested, PHP checks if there's already an identical persistent connection (that remained open from earlier) - and if it exists, it uses it. If it does not exist, it creates the link. An 'identical' connection is a connection that was opened to the same host, with the same username and the same password (where applicable).Summary: Connection identified by host|username|password 2)
An important summary. Persistent connections were designed to have one-to-one mapping to regular connections. That means that you should always be able to replace persistent connections with non-persistent connections, and it won't change the way your script behaves. It may (and probably will) change the efficiency of the script, but not its behavior!Summary: Persistent and temporary connections behave equally. 3) int mysql_insert_id ([int link_identifier]) Well, if the same link_identifier is used for two(or many more) simultaneous clients, does mysql_insert_id() return the correct ID of the last operation with the same client or does it just return the last insert_id of another client on the same persistent connection. I can´t imagine that´s the case, I´d expected a big, big warning then, but I just want to be sure. Having a quick look at source code of php_mysql_do_open... and mysql_insert_id did not reveal any magic logic behind the scenes (I only looked at "hashed_details", which consists of the three values mentioned above. This message was caused by a guess, I did not check behaviour yet. Well, maybe I was to paranoid, but a small confirmation I was would be nice. André -- · André Langhorst · t: +49 571 3201801 · · waldschrott@php.net · m: +49 173 9558736 · · PHP Quality Assurance · http://qa.php.net ·