473,320 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

connection specific question

Hello,

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. 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?

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()". 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.

Thanks very much in advance.
Jun 19 '07 #1
4 1524
On Jun 19, 7:09 pm, Marcus <JumpMan...@aol.comwrote:
Hello,

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. 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?
Confirmed.

Jun 19 '07 #2
..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
Jun 19 '07 #3
Thank you both very much for the quick replies. :-)
Jun 19 '07 #4
In our last episode,
<6-******************************@insightbb.com>,
the lovely and talented Marcus
broadcast on comp.lang.php:
Hello,
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. 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?
I don't know what you mean by confirmation. The function as defined in the
manual clearly states what happens when the link is not specified,
namely that it defaults just as you described above.
I just want to avoid the scenario where persons A and B are accessing
the same script,
Really? Or different instances of 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()". 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.
First, there is no law that says you must omit default parameters if you
can. Sometimes it is a good idea to make them explicit, and it is always
never wrong to do so.

Second, I'm pretty sure you haven't figured out how two users can access the
same script, but that you mean two instances of the same script are running
at the same time. There are ways the two instances of the same script can
step on the database in such a way as to produce unexpected results --- such
as one writes to a table between queries by the other when you are counting
on the queries being sort-of simultaneous. (That is really a database
problem and it has a database solution, namely locking, but almost always
if you are cagey with your query you can avoid the necessity.) But the two
instances of the script will not mistake each other's resources.

--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 580 days to go.
Owing to googlegroups not screening users to eliminate spammers and other
USENET abusers, I do not see most posts from googlegroups.
Jun 19 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jozef | last post by:
Hello, When an Access program connects to a database, is there a unique connection id? I've used the User Roster to check connections, but just wondering if there was two machines with the same...
6
by: Sharon | last post by:
Hi all. I'm trying first time async socket connection. In all the examples i've seen, the server connection is closed when the message is complete. Is it common to close the connection after...
9
by: Full Name | last post by:
Hi, I am a novice programmer. I am trying to write a server-client program as a personal project. I have googled my ass off but I can't seem to find usefull information about this. Can anyone...
35
by: Terry Jolly | last post by:
Web Solution Goal: Have a global database connection Why: (There will be 30+ tables, represented by 30+ classes) I only want to reference the database connection once. I put the connection...
4
by: seets375 | last post by:
Hi, I have two ethernet interfaces on my system, with IPs assigned to the interfaces from different subnets (e.g. eth1 - 10.10.10.10 and eth2 - 20.20.20.20 ). I'm connecting these interfaces to...
2
by: Venkata Narayana | last post by:
Hi, You all may be knowing that Connection.isClosed() does not tells us if the underying DB connection is active or not; it only checks if Connection.close() had been previously called or not....
16
by: crbd98 | last post by:
Hello All, Some time ago, I implemented a data access layer that included a simple connectin pool. At the time, I did it all by myself: I created N connections, each connection associated with...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
13
by: Jennifer.Berube | last post by:
well I'm not sure how to go about making my SQL connection string... The code below is what I need to replace with my SQL connection...I just don't know if that code is for DSN or access... I...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.