我的 scirpt 中有 eror,我只想显示 siswa 详细信息数据
错误号:1066
不唯一的表/别名:"siswa">
从 (
kelas
,siswa
) 中选择 * 加入siswa
siswa
。kelas_id
=kelas
.id
其中nis
= '1001'文件名: C:/xampp/htdocs/konsultasi/system/database/DB_driver.php
行号:691
我的控制器 :
public function siswa_detail($id)
{
$detail = $this->m_datas->detail_data($id);
$data['detail'] = $detail;
$this->load->view('templates/header');
$this->load->view('v_bk/view_siswa_detail', $data);
$this->load->view('templates/footer');
}
我的模型 :
public function detail_data($id = NULL)
{
$this->db->select('*');
$this->db->from('siswa');
$this->db->join('kelas', 'siswa.kelas_id = kelas.id');
$query = $this->db->get_where('siswa', array('nis' => $id))->row();
return $query;
}
您必须删除$this->db->from('siswa')
public function detail_data($id = NULL)
{
$this->db->select('*');
$this->db->join('kelas', 'siswa.kelas_id = kelas.id');
$query = $this->db->get_where('siswa', array('nis' => $id))->row();
return $query;
}
最好在连接中插入"左"或"右"。
$this->db->join('kelas', 'siswa.kelas_id = kelas.id', 'left');