mercredi 1 juillet 2015

Multiple browser connections getting the same DB object

Running two concurrent scripts that I want to access the database sequentially so that each's autoincrement primary keys are sequential. i.e. running them both (instance A and instance B) at the time will lead to

1-A, 2-A, 3-A, 1-B, 2-B, 3-B

However, currently I get

1-A, 1-B, 2-A, 2-B ,3-A ,3-B

After transactions and locking tables didn't work as I would have expected I did some deeper looking and it appears that both scripts (even when run in different browsers) are getting the same connection. So this would not allow one to block the other. Is there anything I can do to force them to get different connections (changing to mysqli or PDO is not an option as this is an existing system)

Chrome:

object(DB_mysql)#10 (26) {
  ["phptype"]=>
  string(5) "mysql"
...

Firefox

object(DB_mysql)#10 (26) {
  ["phptype"]=>
  string(5) "mysql"
...

Aucun commentaire:

Enregistrer un commentaire