title: How to write database queries in helper in CodeIgniter 4
body: <p>I am using CodeIgniter 4. First I write this to get records from the database, but this shows me an error ( Call to a member function <code>table()</code> on null)</p>
  
  <pre><code>$CI = &amp; get_instance();
  $CI -&gt; db -&gt; select('*');
  $CI -&gt; db -&gt; from($table_name);
  </code></pre>
  
  <p>Then I read from documentation and write this</p>
  
  <pre><code>$db-&gt;table("tablename");
  </code></pre>
  
  <p>But this method also failed.</p>