$u = M('r.goods');$u->startTrans();$arr = $u->lock(true)->select(8);……
Note that I did not commit the transaction OH
Now the question is: How do I test the lock?
Online said: "To test the status of the lock, you can use the MySQL command Mode, open two windows to do the test." ”
I opened the two command line window A and B,a window to open the transaction, and then SQL Lock query, b window does not do any action, directly execute the same lock query, feel the "lock Wait" status, no problem.
But why I write the code above the same do not commit the transaction, why refresh two times the page does not "lock, page card master" Feeling Ah, is the PHP script after execution, the open transaction "automatic invalidation", or what happened, or I wrote the code has a problem, How can you not test the same effect as the command-line window?
Another question, I do not open a transaction above the b window, just execute lock query, this will also be affected? Is it necessary for the lock to take effect in the transaction block, while the other queries are not necessarily in the transaction, as long as the SQL statement with the lock query is affected by the previous transaction?
So why didn't I write the code to test this effect?
Reply content:
$u = M('r.goods');$u->startTrans();$arr = $u->lock(true)->select(8);……
Note that I did not commit the transaction OH
Now the question is: How do I test the lock?
Online said: "To test the status of the lock, you can use the MySQL command Mode, open two windows to do the test." ”
I opened the two command line window A and B,a window to open the transaction, and then SQL Lock query, b window does not do any action, directly execute the same lock query, feel the "lock Wait" status, no problem.
But why I write the code above the same do not commit the transaction, why refresh two times the page does not "lock, page card master" Feeling Ah, is the PHP script after execution, the open transaction "automatic invalidation", or what happened, or I wrote the code has a problem, How can you not test the same effect as the command-line window?
Another question, I do not open a transaction above the b window, just execute lock query, this will also be affected? Is it necessary for the lock to take effect in the transaction block, while the other queries are not necessarily in the transaction, as long as the SQL statement with the lock query is affected by the previous transaction?
So why didn't I write the code to test this effect?
Where is the great God, where is the great God? , help to see Ah, why I open a number of pages to test the effect of the lock does not come out?