[eluser]Michal1[/eluser]
Hi,
so I have a problem with retrieving number of rows in one of my function. In my model I have
Code:
public function get_comments()
{
$this->db->where("article_id",$this->uri->segment(3));
$this->db->order_by("id","asc");
$query=$this->db->get('comments');
$number=$query->num_rows();
return $query->result();
return $number->result();
}
Then in controller
Code:
if ($rows=$this->single_model->get_comments())
{
$data['number']=$number;
}
$this->load->view('single_view',$data);
and now I want to echo num of rows so in view i have a classic foreach loop and inside of it
Code:
echo $row->number();
But instead of number I receive word "array".
What am I doing wrong guys? Thank you