I have a code that takes the data from the database and shows it in a table. I need only the first two records to appear. For this I put a limit on my code. But it is not limiting, but taking the total and decreasing by the number.
EX: $this->db->limit(0,5);
In that code it would take the total number of records minus the 5 that is in the code and show what was left. I need him to get the total and show only 2 of those records.
MODEL:
public function getDoisLaudos($vei, $est, $urb, $rur, $aca) {
$this->datatables->select('ls.la_id, ls.la_tipo, ls.la_data, usu.usr_nome, disp.dsp_nome, ls.la_densidade, ls.la_nivel, ls.la_zona, ls.la_status');
$this->datatables->from('ls');
$this->datatables->join('usu', 'ls.usr_id = usu.usr_id');
$this->datatables->join('disp', 'ls.dsp_id = disp.dsp_id');
$this->datatables->join('empresa', 'empresa.emp_id = usu.emp_id');
$this->datatables->where('usu.emp_id = ' . $this->session->userdata('emp_id') . ' AND usu.usr_nivel<>0');
$this->db->limit(0,5);
$this->datatables->unset_column('ls.la_id');
$this->datatables->unset_column('ls.la_status');
$this->datatables->add_column('Ações', '$1', 'get_buttons_laudos(ls.la_id, ls.la_status, ls.la_tipo,' . $aca . ')');
$this->datatables->edit_column('ls.la_tipo', '$1', 'trataLauTipo(ls.la_tipo,' . $vei . ',' . $est . ')');
$this->datatables->edit_column('ls.la_data', '$1', 'tratarDataHora(ls.la_data)');
$this->datatables->edit_column('ls.la_zona', '$1', 'trataLauPerimetro(ls.la_zona,' . $urb . ',' . $rur . ')');
$this->datatables->edit_column('ls.la_status', '$1', 'trataLauStatus(ls.la_status)');
return $this->datatables->generate();
}
Controller:
public function generateTable() {
echo $this->ML->getDoisLaudos($this->lang->line("con_laudo_tip_insp_v"), $this->lang->line("con_laudo_tip_insp_e"), $this->lang->line("con_laudo_per_insp_u"), $this->lang->line("con_laudo_per_insp_r"), $this->lang->line("con_laudo_acoes_insp"));
}