how to use get_instance() in custom library file in codeigniter
<p>here is my custom class in library folder in codeigniter</p>

<pre><code>class Commonlib {

        public function __construct()
        {      
                 $ci=&amp; get_instance();
                 $ci-&gt;load-&gt;database();
        }
           function getcountries(){

                return  $ci-&gt;db-&gt;get("countries")-&gt;result();
            }
                function cities(){ 
                return  $ci-&gt;db-&gt;get("cities")-&gt;result();
            }
    }
</code></pre>

<p>here is my view </p>

<pre><code>$results=$this-&gt;commonlib-&gt;getcountries();
   foreach ($results as $row)
   { 
       echo '&lt;a   href="#"&gt;'.$row-&gt;country .'&lt;/a&gt;&lt;br&gt;';
   }
</code></pre>

<p>error is Severity: Notice  Message: Undefined variable: ci
how to load database in library construct function</p>