I'm trying to bring information from two two tables
my controller:
public function add(){
$data = array(
'separaciones' => $this->Modeltarima->getSeparaciones(),
'calidades' => $this->Modeltarima->getDetalle(50)
//Aqui no entiendo como puedo hacer esto, ¿array bidimensional? se puede ver que solo pase el numero "50" para hacer la prueba de la imagen.
);
$this->load->view('content/head');
$this->load->view('content/aside');
$this->load->view('pages/proceso/tarimas/viewgenerar',$data);
$this->load->view('content/footer');
$this->load->view('content/scrips/proceso/srcontrols');
}
My model:
public function getDetalle($id){
$this->db->select('a.*,d.id as idcal, d.nombre as cal');
$this->db->from('separacion_detalles a');
$this->db->distinct();
$this->db->join('calidad d', 'a.calidad = d.id');
$this->db->where('a.separacion',$id);
$result = $this->db->get('separacion_detalles');
return $result->result();
}
getDetalle(id)
what it does is return the name of the qualities that belong to that separation.
public function getSeparaciones(){
$result = $this->db->get('separacion');
return $result->result();
}
getSeparacion(id)
we simply show the separations that are registered.
Something a little explained in json of how I imagine it
"separaciones": [{
"id": "50",
"hora": "15:04:12",
"calidades":[ {
"id":"10",
"nombre":"CUARTA",
"cajas":0
},
{
"id":"30",
"nombre":"CALIBRE 12?S",
"cajas":0
},
]
},
{
"id": "51",
"hora": "13:04:00",
"calidades":[ {
"id":"10",
"nombre":"CUARTA",
"cajas":0
},
{
"id":"30",
"nombre":"CALIBRE 12?S",
"cajas":0
},
]
}
]
How could I do that?