Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8489459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:50:08+00:00 2026-06-10T21:50:08+00:00

Can anyone test mysql table lock using 2 php scripts. And mysql_query(). I tried

  • 0

Can anyone test mysql table lock using 2 php scripts. And mysql_query().

I tried for a day but i couldn’t get table locked.

I want when one php script uses mysql table all other scripts wouldn’t have access to it.

Can you provide 2 simple tested php scripts. And if you can show how they work online it would be perfect.

But it should be so that when first script works and locks mysql table other scripts should wait for its turn.

Like a queue only one script can access myisam mysql table at the same time. But please test your script before answer because i tried many things many advises and nothing works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:50:10+00:00Added an answer on June 10, 2026 at 9:50 pm

    I wouldn’t advise locking db tables explicitly if it is not aimed to manage complex db logic at transaction level. The queries will still be sent out, but fail due to the lock or worse other transactions become deadlocked because of a lock acquired at the wrong time.

    As a consequence you are like to tank any semblance of performance in the application.

    Edit:

    http://dev.mysql.com/doc/refman/5.1/en/lock-tables.html

    The documentation for mysql gives a detailed explanation of how the locks operate. Locks are acquired for the session using it, so if you want your session to not have access to certain tables and aliases, then you want to lock everything besides the tables you want to deny your session access to.

    Not sure what locks you wish to test as an example.

           define("READ_LOCK", 0)
           define("WRITE_LOCK",1) 
           function lock_on_to_tables ($Tables, $lockType=0)
           {
             $sql = "LOCK TABLES "
            foreach ($Tables as $table)
               $sql .=  $table . " ,";
             $sql = substr($sql, 0, -1); // cut off last comma
             $sql .= $lockType ? " WRITE" : " READ;
             mysqli_query($sql); // or pdo or whatever is in use.  
           }
    

    Unlock is just

      mysqli_query("UNLOCK TABLES") ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can anyone tell me how to get websnapr.com screen shoot in inside a MySQL
I built this query, but I get a weird error, can anyone help me
Can anyone tell me why this code would not be working? $('body').on('test', function() {
Can anyone notice an error in this coding??? NSString *textFilePath = [[NSBundle mainBundle] pathForResource:@test
I'm having a problem getting this test case to work. Can anyone point me
Can anyone help - this is driving me mad. I am calling a mysql
I am new to mysql but have recently tried doing some tutorials to advance
I just can't figure out why i get the error message, I have tried
I'm trying to get started with Hibernate, but can't insert data, for some reason.
Can anyone help me fix this MySQL query? I cant figure out what i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.