当连接到具有联接的表时,在此函数内出现错误。
我发现的错误
遇到未捕获的异常类型:错误消息:调用 未定义的方法CI_DB_mysqli_driver :: select()
我的代码是:
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
}
我在google上搜索了这个问题,但在执行get()时发现了问题,但已经有了。有帮助吗?
答案 0 :(得分:0)
请确保您的模型正在扩展代码CI_Model,并且还要在config文件夹下的autoload.php中加载Databse驱动程序。