title: Codeigniter active record sql error
body: <p>I am using the <code>get_where()</code> function in codeigniter, and I am getting mysql errors, dependent on what I set the limit and offset too, for example this code, </p>
  
  <pre><code>$this-&gt;db-&gt;get_where('em_user', $whereArr, 30, 0)-&gt;num_rows()
  </code></pre>
  
  <p>returns a mysql error that looks like this, </p>
  
  <blockquote>
    <blockquote>
      <p>Error Number: 1064</p>
    </blockquote>
    
    <p>You have an error in your SQL syntax;
    check the manual that corresponds to
    your MySQL server version for the
    right syntax to use near 'WHERE
    <code>email</code> = 'your@emailaddress.com' AND
    <code>password</code> = 'letmein' LIMIT 1' at
    line 2</p>
    
    <p>SELECT * WHERE <code>email</code> =
    'your@emailaddress.com' AND
    <code>password</code> = 'letmein' LIMIT 1</p>
  </blockquote>
  
  <p>However if I run this code, </p>
  
  <pre><code>$this-&gt;db-&gt;get_where('em_user', $whereArr, 30, 30)-&gt;num_rows()
  </code></pre>
  
  <p>it seems to run fine, it seems to run fine, it returns no results but I don not get the error(I assume the no results is because there is an offset of 30 and I only have 2 records in my table).</p>
  
  <p>The sql that this code produces looks like this, </p>
  
  <pre><code>SELECT * FROM (`em_user`) WHERE `email` = 'your@emailaddress.com' AND `password` = 'letmein' LIMIT 30, 30
  </code></pre>
  
  <p>I dont understand how having a limit of 1 at the end of query can cause so much grief, can anyone enlighten me please?</p>