Wednesday, August 9, 2017

Contoh Query dan inisial dalam pemanggilan banyak id Sql Model Codeigniter

Contoh penggunaan model dan relasinya:

 // get data by id
function get_by_id($id)
    {
        $this->db->where($this->id, $id); 
        $this->datatables->select('naco.id_company,   mas_order.id_company_payer,  mas_order.id_reference_no,id_order_info,order_no,id_inspection_type,id_media,date_order,contact_person,position_person,no_person,
naco.name_company as naco, ref_reference.name_reference as noref, date_reference_no, sgs_order,oc_signer,position,
copa.name_company as copa, advanced_payment,buyer
');

$this->datatables->join('mas_company as naco', 'mas_order.id_company = naco.id_company','left');
$this->datatables->join('mas_company as copa', 'mas_order.id_company_payer = copa.id_company','left');

 $this->datatables->join('ref_reference', 'mas_order.id_reference_no=ref_reference.id_reference_no');

        return $this->db->get($this->table)->row();
}



Pengertian :
Inisial pada nama_table.id_table harus di jabarkan dan bila terjadi ambiguous harus mempergunakan fungsi as untuk inisial nama nail.

No comments:

Post a Comment

author
Ade Pramono.AR
Selamat datang di blog kami, silahkan cari kebutuhan serta permasalahan anda di sini. The real programmer Copy/Paste hehehheeheh