title: How to lock table with Laravel?
body: <p>I want to lock a table inside a transaction. Something like this:</p>
  
  <pre><code>  DB::transaction(function (){
      DB::statement('LOCK TABLES important_table WRITE');
      //....
    });
  </code></pre>
  
  <p>However, the line <code>DB::statement('LOCK TABLES important_table WRITE');</code> always triggers the following error:</p>
  
  <blockquote>
    <p>SQLSTATE[HY000]: General error: 2014 Cannot execute queries while
    other unbuffered queries are active.  Consider using
    PDOStatement::fetchAll().  Alternatively, if your code is only ever
    going to run against mysql, you may enable query buffering by setting
    the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. (SQL: LOCK TABLES
    officeSeal WRITE)</p>
  </blockquote>
  
  <p>How can I lock the table in Laravel?</p>