|  | Posted by Michael Fesser on 06/19/07 23:22 
..oO(Marcus)
 >Whenever the PHP documentation references the optional link_identifier
 >parameter in many mysql related functions (such as mysql_query,
 >mysql_insert_id, etc.), it says:
 >
 >"The MySQL connection. If the link identifier is not specified, the last
 >link opened by mysql_connect() is assumed. If no such link is found, it
 >will try to create one as if mysql_connect() was called with no
 >arguments. If by chance no connection is found or established, an
 >E_WARNING level warning is generated."
 >
 >I know that functions such as mysql_insert_id are connection specific,
 >but I have not been able to find any info explicitly stating that it is
 >also connection specific when link_identifier is omitted.
 
 If the link identifier is omitted, the statement from above applies,
 i.e. the last opened link from within the same script will be used.
 
 >I am about
 >99% sure that it would still be connection specific because otherwise
 >these functions would be pretty useless, but could someone please
 >confirm this?
 
 It is always connection-specific.
 
 >I just want to avoid the scenario where persons A and B are accessing
 >the same script, but by the time person A runs mysql_insert_id (or some
 >other mysql function), person B's connection is technically "the last
 >link opened by mysql_connect()".
 
 This can't happen. Two people accessing the site at the same time means
 two different script calls, two different mysql_connect() calls, hence
 two different connections => mysql_insert_id() will work as expected.
 
 The "last link opened by mysql_connect()" doesn't mean all opened links
 from all running scripts on the server, it just refers to the currently
 running script from the current user.
 
 >In other words, I want to make sure
 >that I can omit the link_identifier and still be confident that
 >different connections will not affect each other.
 
 Connections from different scripts won't affect each other.
 
 Micha
  Navigation: [Reply to this message] |