Reputation: 87
I mean if I create a dynamic webpage with php. If user enter "1", multiple queries will run if user enter "0", only single query will run. For multiple queries I need to use autocommit, rollback and commit so that if one query fails all queries will rollback. And for single query I don't need those functions.
My question is that if user1 from a pc entered "1" and user2 from other pc entered "0". Since user1 entered "1", autocommit is going to be false. Does that effect user2?
Same for rollback and commit. If user1 queries failed it calls for rollback does it effect user2 query?
Please help me I'm new to this concept.
Upvotes: 0
Views: 111
Reputation: 23001
Each connection is treated as a separate entity or session, no matter if it's the same login information or different mysql users. When you start a transaction with begin_transaction, it sets the transaction mode for that session only. User1 and User2, despite logging in with the same information via PHP, are treated as separate sessions.
https://www.php.net/manual/en/mysqli.begin-transaction.php
https://dev.mysql.com/doc/refman/8.0/en/commit.html
Upvotes: 1