CodeIgniter table class loops through db records 3 times - why?
This is my controller code (using Colin Williams' Template class):
$this->load->library('table');
$table['records'] = $this->db->get_where('data', array('category_1' => 'weight'));
$this->template->write_view('content', 'vw/weight_vw', $table, TRUE);
And my view code:
<div class="grid_16">
<?php echo $this->table->generate($records); ?>
</div>
Look at what I get
2 1 29 2011-01-01 10 weight
4 1 29 2010-11-03 11 weight
5 1 29 2011-05-02 10 weight
6 1 42 2011-07-11 23 weight // the database only has records up to here
2 1 29 2011-01-01 10 weight // from here on it's repeated twice
4 1 29 2010-11-03 11 weight
5 1 29 2011-05-02 10 weight
6 1 42 2011-07-11 23 weight
2 1 29 2011-01-01 10 weight
4 1 29 2010-11-03 11 weight
5 1 29 2011-05-02 10 weight
6 1 42 2011-07-11 23 weight
开发者_Go百科
Any ideas why this is happening? None of my code is inside a loop or anything like that.
Use
$this->output->enable_profiler()
to see the db queries.
Take the query and run it against your db directly.
It's most likey you have a bad join in your database model.
精彩评论