title: How to write mysql query with WHERE 1 in Codeigniter Active record form
body: <p>How to write the following query</p>
  
  <pre><code>SELECT * FROM `TABLE_NAME` WHERE 1 
  </code></pre>
  
  <p>in codeigniter Active record form ?</p>
  
  <p>I tried something like:</p>
  
  <pre><code>$this-&gt;db-&gt;select('*');
  $this-&gt;db-&gt;from('TABLE_NAME');
  $this-&gt;db-&gt;where('1');
  </code></pre>
  
  <p>But I am getting the following error:</p>
  
  <p>Error Number: 1054</p>
  
  <p>Unknown column '1' in 'where clause'</p>
  
  <pre><code>SELECT * FROM (`TABLE_NAME`) WHERE `1` IS NULL
  </code></pre>
  
  <p>I am using same method for selecting values from database. I just pass the columns, condition and table name. My problem is, when I want to get all the data from a table, what will I give in the where clause ?</p>
  
  <p>Following is my query section:</p>
  
  <pre><code>function get($fields,$table,$where)
  {
       $this-&gt;db-&gt;select($fields);
       $this-&gt;db-&gt;from($table);
       $this-&gt;db-&gt;where($where); 
       $q = $this-&gt;db-&gt;get();
       if($q-&gt;num_rows() &gt; 0)
       {
           foreach($q-&gt;result() as $row)
           {
                $data[] = $row;
           } 
           return $data; 
        }
   } 
  </code></pre>
  
  <p>Following how I call the function in controller:</p>
  
  <pre><code>$data['details'] = $this-&gt;MODEL_NAME-&gt;get("*",PREFIX."TABLE_NAME",1);
  </code></pre>
  
  <p>The model here is loaded from autoload.</p>