Singleton and transactions
Posted: Sun Feb 21, 2010 1:35 am
Hi!
I have a question about singleton and transactions in a mysql database.
Recently I built an application which uses PDO to access the mysql database and I'm using Singleton pattern to allow only one instance of the connection to the bd.
I use transactions in most of the database operations. So, let's show this scenario: 5 users in their own computers in 5 different pages of my application. They are ready to click a button that triggers operations (which use BD transactions).
¿Does PHP creates a DB instance for each one of these 5 users? or ¿Does PHP share the same DB instance for these 5 users?
¿How does Singleton handle the particular transaction for each user?
For instance, let's say that the 5 users click at the same time. ¿Could this possibly lead to errors on db operations?
I would really appreciate your help.
Regards
I have a question about singleton and transactions in a mysql database.
Recently I built an application which uses PDO to access the mysql database and I'm using Singleton pattern to allow only one instance of the connection to the bd.
I use transactions in most of the database operations. So, let's show this scenario: 5 users in their own computers in 5 different pages of my application. They are ready to click a button that triggers operations (which use BD transactions).
¿Does PHP creates a DB instance for each one of these 5 users? or ¿Does PHP share the same DB instance for these 5 users?
¿How does Singleton handle the particular transaction for each user?
For instance, let's say that the 5 users click at the same time. ¿Could this possibly lead to errors on db operations?
I would really appreciate your help.
Regards