0
我设法获取返回的数据行以进行特定搜索,但无法获取已找到的行数。这里是我的代码如何获取Codeigniter中的数据库查询后的行数?
我的控制器
function searchdata(){
$result = $this->posts->search($_POST['searchterm']);
$data['posts']= $result['rows'];
$data['num_results']= $result['num_rows']; // num_rows is the number of rows returned from a search
$this-> load-> view('results_index',$data);
}
我的模型
function get_search($keyword)
{
$q = $this-> db-> select('*')-> from ('blog');
$q= $this->db->like('title',$keyword);
$q= $this->db->or_like('description',$keyword);
$results['rows']= $q-> get()-> result();
//$results['num_rows']= $q-> num_rows(); <--- this doesn't work, invalid method, commented out
return $results;
}
如果有帮助,这http://ellislab.com/codeigniter/user-guide/database/results.html也许能帮助你。我以为它会
谢谢你的家伙。
完美的作品。当这个错误再次发生时,我会更关心这些事情。谢谢! – Matt