接收错误,例如非唯一表/别名:' provinces' ,下面的函数是模型函数,我在模型中创建这个函数但是得到错误表/别名
function get_data_three_tbl(){
$this->db->select('blood_donors.id, blood_donors.full_name, blood_donors.area, blood_donors.email, blood_donors.phone, provinces.province_name,districts.district_name, tehsils.tehsil_name, blood_groups.group_name');
$this->db->from ( 'blood_donors, provinces, districts, tehsils, blood_groups ' );
$this->db->where('blood_donors.is_deleted',1);
$this->db->join('provinces','provinces.province_id = blood_donors.province');
$this->db->join('districts','districts.district_id = blood_donors.district');
$this->db->join('tehsils','tehsils.tehsil_id = blood_donors.tehsil');
$this->db->join('blood_groups','blood_groups.id = blood_donors.blood_goup');
$query = $this->db->get();
if ($query->num_rows() > 0)
return $query->result_array();
else
return FALSE;
}
答案 0 :(得分:0)
将from()
来电更改为
$this->db->from('blood_donors');
join
语句负责其他表。在from
和join
语句中包含表名是导致非唯一错误的原因。