I would like to test the InnoDB of the row lock how can not test it? Help me look at my code, right?

Source: Internet
Author: User
$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?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.