I can't call the table that has column contains brackets ().
How do I call the table and can I aliases the column name?
The table that contains brackets is material detail and the column is Panjang(mm) and Lebar(mm)
My Controller :
public function GetDataID()
{
$id = $this->input->post('id');
$cek = $this->list->getDetailBagJob2($id);
if ($cek->num_rows() == 0) {
$bagianjob = $this->list->getDetailBagJob1($id)->result();
echo json_encode($bagianjob);
} else {
$bagianjob = $this->list->getDetailBagJob2($id)->result();
echo json_encode($bagianjob);
}
}
My Models :
public function getDetailBagJob1($id)
{
$this->db->from('opdetailbagianjob');
$this->db->join('mbagianjob', 'opdetailbagianjob.ID_Bagian_Job=mbagianjob.ID_Bagian_Job');
$this->db->join('mmaterial', 'opdetailbagianjob.ID_Gramatur=mmaterial.ID_Material');
$this->db->join('mmaterial_type', 'opdetailbagianjob.ID_Bahan=mmaterial_type.ID_Mat_Type');
$this->db->join('mmaterialdetail', 'opdetailbagianjob.ID_Ukuran=mmaterialdetail.ID_Mat_Detail');
$this->db->where('No_Enquiry', $id);
return $this->db->get();
}
public function getDetailBagJob2($id)
{
$this->db->select('opdetailbagianjob.*,opdetailbagianjob.Keterangan as keteranganbagjob,mbagianjob.*,mmaterial.*,mmaterial_type.*,mmaterialdetail.*');
$this->db->from('opdetailbagianjob');
$this->db->join('mbagianjob', 'opdetailbagianjob.ID_Bagian_Job=mbagianjob.ID_Bagian_Job');
$this->db->join('mmaterial', 'opdetailbagianjob.ID_Gramatur=mmaterial.ID_Material');
$this->db->join('mmaterial_type', 'opdetailbagianjob.ID_Bahan=mmaterial_type.ID_Mat_Type');
$this->db->where('No_Enquiry', $id);
return $this->db->get();
}
My Ajax To call the response in console :
function ambilenquiry(id) {
$.ajax({
url: "<?php echo base_url(); ?>Enquiry/GetDataID",
type: "POST",
dataType: "json",
data: {
"id": id
},
success: function(data) {
console.log(data);
},
error: function(data) {
alert('Gagal');
}
});
}
I expect the output is success response, but the response show error with
jquery-3.4.1.min.js:2 POST http://10.3.1.10:81/gapcalc/Enquiry/GetDataID 500 (Internal Server Error)