• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Call CI DB library in custom made helper function

#1
[eluser]Blue Sapphire[/eluser]
Hi!
I have following code of custom made helper function:

Code:
function mCountry(){
    
    $query = $this->db->query('select * from fa_country');
    
    if($query->num_rows() >0)
    {
        $nbrows = $query->num_rows();
        foreach($query->result() as $res){
            $rec['id']      = $res->id;
            $rec['iso']     = $res->iso;
            $rec['name']    = $res->name;
            $rec['iso3']    = $res->iso3;
            $rec['numcode'] = $res->numcode;
            $arr[] = $rec;            
    }
        $jsonresult = JEncode($arr);
        echo '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';    
        //echo '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';
}

In above mentioned code, how can I call, DB laibrary of CI. Because with current syntax, it is giving me error of "Call to a member function on a non-object............." .



Can anyone guide me in this regards.

Thanks in advance


Messages In This Thread
How to Call CI DB library in custom made helper function - by El Forum - 07-30-2008, 12:27 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.