Code Comments
Programming Forum and web based access to our favorite programming groups.Hello all, Sorry if you are getting this twice I am not sure if my other one actually made it or not. I know that this wouldn't be an issue with a regular connection but using persistent connection suppose I have script.php and there are 2 instances running. If I do an INSERT followed by mysql_insert_id() in instance1, but between those 2 statments instance2 does an INSERT, would this introduce a kind of race condition where instance1 would get the insert id of instance2? And the same thing with mysql_select_db(). If instance1 selects databaseA, and instance2 runs a SELECT statement thinking it is using databaseB wouldn't that cause an error? TIA, Me
Post Follow-up to this message"Dumbass" <blah@hotmail.com> wrote in message news:1162l1sa3pujo12@corp.supernews.com... > Hello all, > > Sorry if you are getting this twice I am not sure if my other one > actually made it or not. > > I know that this wouldn't be an issue with a regular connection but > using persistent connection suppose I have script.php and there are 2 > instances running. > > If I do an INSERT followed by mysql_insert_id() in instance1, but > between those 2 statments instance2 does an INSERT, would this introduce > a kind of race condition where instance1 would get the insert id of > instance2? > > And the same thing with mysql_select_db(). If instance1 selects > databaseA, and instance2 runs a SELECT statement thinking it is using > databaseB wouldn't that cause an error? > > TIA, > Me The answers to your questions are 'no', each instance will receive the insert id associated with its connection id and neither will trip up over which database the other is currently accessing... Norm -- FREE Avatar hosting at www.easyavatar.com
Post Follow-up to this messageNorman Peelman wrote: > "Dumbass" <blah@hotmail.com> wrote in message > news:1162l1sa3pujo12@corp.supernews.com... > > > > The answers to your questions are 'no', each instance will receive the > insert id associated with its connection id and neither will trip up over > which database the other is currently accessing... > > Norm And how do you know this?
Post Follow-up to this messageIn article <1163lqvahdrvt6f@corp.supernews.com>, Dumbass <blah@hotmail.com> wrote: > Norman Peelman wrote: > > And how do you know this? Simple. It's the way connections to MySQL are created by PHP. You can download the source to PHP and MySQL and check for yourself. -- DeeDee, don't press that button! DeeDee! NO! Dee...
Post Follow-up to this messageMichael Vilain wrote: > Simple. It's the way connections to MySQL are created by PHP. You can > download the source to PHP and MySQL and check for yourself. > What kind of answers are those though? "No", "Simple. That's the way it is!" Have you read the source and understand how it works? If so then why didn't you offer an explanation? Not all of us are end user level programmers. Some of us can take a little technical discussion. And explanation like this would have been nice... Persistent resources are per engine. For example, with apache 1.3.x and apache2-prefork mpm, there is one php engine per child. Each engine has it's own persistant resource list. So a script running with 2 instances do not share a single resource. They each use the persistent connection for that instance of the engine. Also because of this there is no such thing as persistent resources for the cli or cgi SAPI's (even if the cgi is ran thru apache) because the engine is created and destroyed for each request, so "the persistent connections simply do no persist".
Post Follow-up to this messageDumbass wrote: > Michael Vilain wrote: > > What kind of answers are those though? "No", "Simple. That's the way it > is!" Have you read the source and understand how it works? If so then > why didn't you offer an explanation? Not all of us are end user level > programmers. Some of us can take a little technical discussion. And > explanation like this would have been nice... > No need to loose the plot - Michael is trying to help to help you here. And the answer is perfectly valid. And a much better answer than 'because the supplier said so'. If you can't be bothered to check the source for yourself but *must* know the answer, TEST IT YOURSELF. C.
Post Follow-up to this message> What kind of answers are those though? "No", "Simple. That's the way it > is!" Have you read the source and understand how it works? If so then > why didn't you offer an explanation? Not all of us are end user level > programmers. Some of us can take a little technical discussion. And > explanation like this would have been nice... Rather than getting nasty at each other ... When the poster means two instances running, I assume it is meant that the script is called simultaneously by to "users" as opposed to simultaneously (sort of) by the same calling program, i.e. same user. I think mysql and php are able to handle this without getting; that is the whole point of persistant connections, otherwise why bother implementing it? Without knowing any of the details, I assume a connection ID is established for each connection, and it is this ID that is used to determine stuff like last_insert etc.
Post Follow-up to this message"Dumbass" <blah@hotmail.com> wrote in message news:1163lqvahdrvt6f@corp.supernews.com... > Norman Peelman wrote: over > > And how do you know this? Because I use PHP/MySQL and I learned, read the docs/manuals/faqs/etc. Bottom line, test it for yourself (as has been suggested) - don't confuse the database connection with the php resource identifier. Norm -- FREE Avatar hosting at www.easyavatar.com
Post Follow-up to this message"Dumbass" <blah@hotmail.com> wrote in message news:1163lqvahdrvt6f@corp.supernews.com... > Norman Peelman wrote: over > > And how do you know this? Because I use PHP/MySQL and I learned, read the docs/manuals/faqs/etc. Bottom line, test it for yourself (as has been suggested) - don't confuse the database connection with the php resource identifier. Norm -- FREE Avatar hosting at www.easyavatar.com
Post Follow-up to this messageMichael Vilain wrote: > Simple. It's the way connections to MySQL are created by PHP. You can > download the source to PHP and MySQL and check for yourself. > What kind of answers are those though? "No", "Simple. That's the way it is!" Have you read the source and understand how it works? If so then why didn't you offer an explanation? Not all of us are end user level programmers. Some of us can take a little technical discussion. And explanation like this would have been nice... Persistent resources are per engine. For example, with apache 1.3.x and apache2-prefork mpm, there is one php engine per child. Each engine has it's own persistant resource list. So a script running with 2 instances do not share a single resource. They each use the persistent connection for that instance of the engine. Also because of this there is no such thing as persistent resources for the cli or cgi SAPI's (even if the cgi is ran thru apache) because the engine is created and destroyed for each request, so "the persistent connections simply do no persist".
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.