我試圖通過'id'格式id調用數據id id = GE-DIS-001 to JOIN table with笨,「未知列 'GE' 的結果 'where子句' 出了什麼問題?用varchar格式調用mysql數據庫的'id',但在'where子句'中調用未知列'GE'
控制器:
public function detail(){
$id = $this->uri->segment(4);
$detail = $this->mcrud->get_detail($id);
$data = array(
'detail'=>$detail,
'lihat' =>$this->mcrud->lihat_komentar($id),
'isi' =>'instrument/read_views');
$this->load->view('layout/wrapper', $data);
}
型號:
public function get_detail($id){
$sql = "SELECT * FROM tbdetail
JOIN tbkalibrasi ON tbkalibrasi.id = tbdetail.id
JOIN tbsupplier ON tbsupplier.namasupplier = tbdetail.namasupplier
WHERE tbdetail.id = {$id}
";
return $this->db->query($sql)->result_array();
}
$ id有什麼? –
id是一個字符串,它的需要引用 –
嘗試打印您的查詢並導致您將得到什麼錯誤....嘗試'print_r($ sql);和print_r($ this-> db-> query($ sql) - > result_array()); ' – Linus