[eluser]hvalente13[/eluser]
I'm trying to get CI to work in the office, but after some time, of trying to do something simple I have to ask.
After connecting to sqlite database, i use pagination and table libraries, and the most odd thing happens: I get repeated columns values.
Instead of getting only a single value for each column i get the same value twice.
The code
Controller:
Code:
class Ocorrencias extends Controller {
function __construct()
{
parent::Controller();
$this->output->enable_profiler(TRUE);
$this->load->helper('url');
$this->load->database();
}
function index()
{
$this->load->library('pagination');
$config['base_url'] = base_url().'index.php/ocorrencias/index/';
$config['total_rows'] = $this->db->count_all('t_ocorrencia');
$config['per_page'] = '10';
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$this->pagination->initialize($config);
$this->load->model('ocr_model');
$data['results'] = $this->ocr_model->get_ocrs($config['per_page'],$this->uri->segment(3));
$this->load->library('table');
$this->table->set_heading('Data', 'Tipo Ocr.', 'Paciente', 'Local', 'Participante');
$this->table->set_caption('Ocorrências');
$data['titulo']="Dial PROg";
$this->load->view('ocr', $data);
}
}
View
Code:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href='<?php echo base_url(); ?>include/estilos.css' type="text/css" media="screen, projection" />
<title>
<?=$titulo?>
</title>
</head>
<body>
<?php echo $this->table->generate($results); ?>
<?php echo $this->pagination->create_links(); ?>
</body>
</html>
And finaly the model
Code:
class ocr_model extends Model {
function __construct(){
parent::Model();
}
function get_ocrs($num, $offset) {
$this->db->select('t_ocorrencia.data as data, t_ocrtipo.tipo_ocr as tipo, (t_pacientes.nome || ", " || t_pacientes.apelido) as nome, t_ocrlocal.local_ocr as local, t_funcionario.funcionario as funcionario');
$this->db->from('t_ocorrencia');
$this->db->join('t_ocrlocal', 't_ocrlocal.localid = t_ocorrencia.local_ocr');
$this->db->join('t_ocrtipo', 't_ocrtipo.tipoocrid = t_ocorrencia.tipo_ocr');
$this->db->join('t_pacientes', 't_pacientes.pacienteid = t_ocorrencia.pacienteid');
$this->db->join('t_funcionario', 't_funcionario.funcionarioid = t_ocorrencia.participante');
$query = $this->db->get('', $num, $offset);
return $query;
}
}
Some can help?
Thanks in advance