Counting the number of results returned by a database query in Codeigniter

zxcbmk

New Member
I am not having much luck detecting when a database query in Codeigniter returns zero results. I have had a good read of the notes on the PHP count function but am none the wiser!I am using a classic MVC structure and call the query/view as follows from the controller:\[code\]$data['result'] = $this->search_model->do_search(set_value('name'));$data['title'] = "Search results";$this->load->view('search_view',$data);\[/code\]The view generates a results table for me OK, but when I try and trap an empty result, the count always returns 1:I have tried \[code\]if count(array($result))\[/code\] and just \[code\]if count($result)\[/code\]So what's a good way to get the count? I'm using Fedora 13 with PHP 5.3.3 on my dev laptop.Thanks for your input
 
Back
Top