Topic: table row locking - what do you think and what is your idea? (Read 1301 times)
OMG!I am geek
Posts: 57
394 credits Members referred : 0
« on: May 23, 2007, 04:45:33 PM »
I start this new thread because the other one discusses a differed table locking problem whith session. This thread is created not for the seesion table locking but for the general table locking problems.
For example the admin and a user try to insert something in users_profile table and there is no locking featcher, which data will be insert and shown at next?
I assume that problem could be solved by only allow only one user to edit/view the same row by checking if this row has an session for a tempoary insert which should be deleted afted the insert in done. What do you think of it?
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6280
38506 credits Members referred : 374
It's time to use PHP5!
« Reply #1 on: May 23, 2007, 04:56:12 PM »
I say this discussion is not related to this class but related to your application, will say is you own decision...
I say this discussion is not related to this class but related to your application, will say is you own decision...
Why this question should not related to this class? This situation is even possible with this class. If a user and the admin updates say the password from a user at the same time. What will be happen, which update will be take place in the users table, which password will be the right one?
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6280
38506 credits Members referred : 374
Why this question should not related to this class? This situation is even possible with this class. If a user and the admin updates say the password from a user at the same time. What will be happen, which update will be take place in the users table, which password will be the right one?
look this class script is not a full function application, the examples are purposed to give you an idea how to use that class. It's up to you as web developer to build an application where this is feature is possible or not.
if you see the replacement of a password by user and admin as a problem you need to find a solution and not the class script
OMG!I am geek
Posts: 57
394 credits Members referred : 0
« Reply #4 on: May 23, 2007, 05:23:10 PM »
ok, you are right but I'm intressed how maybe you or others think of that and if they think that this is a problem or not and maybe you have ideas to solve it.
« Last Edit: May 23, 2007, 05:24:43 PM by tomz »
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 7974
40801 credits Members referred : 3
« Reply #5 on: May 23, 2007, 06:11:26 PM »
In my opinion this is not a problem. First of all why both admin and the user want to change the password at the same milisecond? Isn't that strange?
Even if it happen, the mysql will keep the last one, but no matter what, you can't prevent that. If you lock the row then the first one will save the value. If you don't lock the row the second will save it. So what's the difference?
In my opinion this is not a problem. First of all why both admin and the user want to change the password at the same milisecond? Isn't that strange?
Even if it happen, the mysql will keep the last one, but no matter what, you can't prevent that. If you lock the row then the first one will save the value. If you don't lock the row the second will save it. So what's the difference?
Hm, I think the difference is that we will be able to determine who is the first and who is the second. Otherwise it's random but maybe your are right and it is'nt realy a problem because the insert or update value will be shown after it is done but it would be nice if the user would be informed that the data was changed by sombody else if thise case arises and I dont mean only for the password, it could be happend for every value.
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 7974
40801 credits Members referred : 3
« Reply #7 on: May 23, 2007, 11:49:38 PM »
In order to do what you say, you should keep a file of changes (another table in the db) and run some checks every time someone changes something to an account.
In my opinion this would be needed only to a bank system and only for security reasons, as the possibility of someone changing his/her information while the admin does the same is almost impossible
In my opinion this would be needed only to a bank system ...
There are more real reasons as only the getting money process. For example every time if you sell somthing there could be a problem, every shop solution need a solution like this otherwise you will sell something what was already sold ...
I'm not very closed to mysql but I know that transaction are not possible whis myisam. ok, I don't want to use transactions but is there realy no risk in damaging databases if two users writes at the same time in the same row, dow mysql handle this case one after the other as you said before?
« Last Edit: May 24, 2007, 12:29:23 AM by tomz »
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 7974
40801 credits Members referred : 3
« Reply #9 on: May 24, 2007, 12:43:29 AM »
This is a design problem. The session is not relevant here, as there is no practical reason to hold your shop's inventory in the session right?
When you sell something you update your inventory. If this happened twice at the same time both processes will update, but I again if your code is correct there is no problem. For instance if you say UPDATE products SET sum = sum -1 WHERE productID = X, both processes will update the table.
Regarding transactions I think you can use them since mysql 5.0