Code: Select all
chemical_name_id | chemical_name (table name: ml_chemical_names)
================================
1 | Polysomething
common_name_id | common_name (table name: ml_common_names)
=============================
1 | PMMA
2 | Lucite
3 | Perspex
4 | Plexiglas
material_id | material (table name: ml_materials)
======================
20 | Acrylic
Code: Select all
material_id | common_name_id (table name: ml_materials_common_names)
============================
20 | 1
20 | 2
20 | 3
20 | 4
and
material_id | chemical_name (table name: ml_materials_chemical_names)
===========================
20 | 1
Code: Select all
$this->db->like('cn.common_name', $options['keyword']);
$this->db->or_like('chem.chemical_name', $options['keyword']);
$this->db->join('ml_materials_chemical_names mchem', 'mchem.material_id = m.material_id', 'inner');
$this->db->join('ml_chemical_names chem', 'chem.chemical_name_id = mchem.chemical_name_id', 'inner');
$this->db->join('ml_materials_common_names mcn', 'mcn.material_id = m.material_id', 'inner');
$this->db->join('ml_common_names cn', 'cn.common_name_id = mcn.common_name_id', 'inner');
return $this->db->get('ml_materials m')->result();
Kann jemand helfen?
Mobile version