0
votes

I get error inside thsi function when connect to a table that have a join.

The Error that I find

An uncaught Exception was encountered Type: Error Message: Call to undefined method CI_DB_mysqli_driver::select()

and my code is:

public function get_data($table,$where='',$select='',$join='',$limit='',$start=NULL,$order_by='',$group_by='',$num_rows=0,$csv='') //selects data from a table as well as counts number of affected rows
    {


        // only get data except deleted values
        // $col_name=$table.".deleted";
        // if($this->db->field_exists('deleted',$table) && $show_deleted==0)
        // $where['where'][$col_name]="0";

        $this->db->select($select);
        $this->db->from($table);

        if($join!='')                   $this->generate_joining_clause($join);      
        if($where!='')                  $this->generate_where_clause($where);

        if($this->db->field_exists('deleted',$table))
        {
            $deleted_str=$table.".deleted";
            $this->db->where($deleted_str,"0");
        }

        if($order_by!='')               $this->db->order_by($order_by);
        if($group_by!='')               $this->db->group_by($group_by);




        if(is_numeric($start) || is_numeric($limit))
            $this->db->limit($limit, $start);

        $query=$this->db->get();

        if($csv==1)
        return $query; //csv generation requires resourse ID

        $result_array=$query->result_array(); //fetches the rows from database and forms an array[]

        if($num_rows==1)
        {
            $num_rows=$query->num_rows(); //counts the affected number of rows
            $result_array['extra_index']=array('num_rows'=>$num_rows);  //addes the affected number of rows data in the array[]
        }

        // print_r($this->db->last_query());
        return $result_array; //returns both fetched result as well as affected number of rows 

}

I search about this on google and I find that the problem when do get(), but already have it. any help ?

1
have you loaded your database in controller or in autoload.php - Pradeep
@pradeep, yes its loaded, because of it i feel strange! - Mina Magdy
show also where you r accessing get_data - Pradeep

1 Answers

0
votes

Make sure that your Model is extending code CI_Model and also that you are loading your Databse driver in autoload.php under config folder.