jonny5 Posted July 13, 2006 Share Posted July 13, 2006 I can't seem to find any good documented stuff about this:When a user calls a php page, and another user calls the samecan this result in database inconsistency?which part of query's are executed atomically:none?just 1 query?1 php page?please help me on this one?thanks!!!Jonny;) Quote Link to comment https://forums.phpfreaks.com/topic/14501-php-mysql-page-requests/ Share on other sites More sharing options...
Wildbug Posted July 13, 2006 Share Posted July 13, 2006 You can use [url=http://dev.mysql.com/doc/refman/5.0/en/transactional-commands.html]transactional and locking statements[/url] if you need atomicity over multiple SQL statements (a transaction). Otherwise, for a single query, AFAIK, queries are "atomic" by nature.Of course, I'm refering to SQL commands which change a table in some way (UPDATE, INSERT, or DELETE). SELECTs would be exempt.MySQL (I'm assuming MySQL since you're posting in this forum, otherwise PostGRE, Oracle, whatever) handles the database functions. If a PHP with a table-altering SQL query is requested once, then immediately requested by another user, the inital SQL is carried out, then the second request "sees" the updated table.Does that answer your question? There's plenty of information out there on database concurrency, atomicity, transactions, etc. Much of it is database developer theory and is not of the database user's concern. Quote Link to comment https://forums.phpfreaks.com/topic/14501-php-mysql-page-requests/#findComment-57554 Share on other sites More sharing options...
jonny5 Posted July 13, 2006 Author Share Posted July 13, 2006 Thank you for ur quick response ;)and what about this:<?php//call query to add 1 to some field//call query to substract 1 to same field?>User 1 requestsUser 2 requestscan this happen:u1 addu2 addu1 subu2suboru1 addu2 addu2subu1 subthis can cause inconsistance if you are not using increment or decrement but getting values, changing them and then putting themso are those queries in 1 php page 1 thing? cause i'm still not getting that part :)thanks! Quote Link to comment https://forums.phpfreaks.com/topic/14501-php-mysql-page-requests/#findComment-57578 Share on other sites More sharing options...
dptr1988 Posted July 13, 2006 Share Posted July 13, 2006 I'm worried about the same thing, but was one step behind you in that I was getting/putting the values rather then adding and subtracting them. But your adding/subtracting should work fine, because it doesn't matter what order you do the addition and subtraction. Quote Link to comment https://forums.phpfreaks.com/topic/14501-php-mysql-page-requests/#findComment-57596 Share on other sites More sharing options...
fenway Posted July 13, 2006 Share Posted July 13, 2006 Simply assume that anyone can touch the tables at any time, irrespective of the order of the statements across multiple instances of the same script. Quote Link to comment https://forums.phpfreaks.com/topic/14501-php-mysql-page-requests/#findComment-57630 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.