title: How to lock tables with codeigniter?
body: <p>I have to run this sql routine in a model: </p>
  
  <pre><code>$this-&gt;db-&gt;query('LOCK TABLE orders WRITE');
  $this-&gt;db-&gt;query('TRUNCATE TABLE orders');
  $this-&gt;db-&gt;query('INSERT INTO orders SELECT * FROM orders_tmp');
  $this-&gt;db-&gt;query('UNLOCK TABLES');
  </code></pre>
  
  <p>but I get this error: </p>
  
  <blockquote>
    <p>Error Number: 1192<br>
        Impossible to execute the requested command: tables under lock or transaction running<br>
        TRUNCATE TABLE orders</p>
  </blockquote>
  
  <p>I use MyISAM as DB engine on this table.</p>
  
  <p>Could you please help me?</p>