Codeigniter: Retrieving a variable from Model to use in a Controller
Posted
by Craig Ward
on Stack Overflow
See other posts from Stack Overflow
or by Craig Ward
Published on 2010-03-23T22:21:54Z
Indexed on
2010/03/23
23:13 UTC
Read the original article
Hit count: 392
Hi, I bet this is easy but been trying for a while and can't seem to get it to work. Basically I am setting up pagination and in the model below I want to pass $total_rows to my controller so I can add it to the config like so '$config['total_rows'] = $total_rows;'.
function get_timeline_filter($per_page, $offset, $source)
{
$this->db->where('source', $source);
$this->db->order_by("date", "desc");
$q = $this->db->get('timeline', $per_page, $offset);
$total_rows = $this->db->count_all_results();
if($q->num_rows() >0)
{
foreach ($q->result() as $row)
{
$data[] = $row;
}
return $data;
}
}
I understand how to pass things form the Controller to the model using $this->example_model->example($something);
but not sure how to get a variable from the model?
© Stack Overflow or respective owner