简体   繁体   English

如何计算返回的行数?

[英]How do I count the number of rows returned?

I'm using My_model (developed by jamierumbelow) for my small application. 我正在将My_model (由jamierumbelow开发)用于我的小型应用程序。

I've got a basic user search and I'm trying to paginate the results but I can't figure out how to get the total number of rows returned by the result. 我已经进行了基本的用户搜索,并试图对结果进行分页,但是我不知道如何获取结果返回的总行数。 This is the code I have in my controller: 这是我控制器中的代码:

protected function get_users(){


$this->load->model('user_model');


$this->data["users"]  = $this->user_model;

if($this->input->post('country')){
    $this->data["users"] = $this->data["users"]->search('country', $this->input->post('country'));
}

if($this->input->post('city')){
    $this->data["users"] = $this->data["users"]->search('city', $this->input->post('city'));
}


if($this->input->post('forename')){
    $this->data["users"] = $this->data["users"]->search('forename', $this->input->post('forename'));
}


if($this->input->post('surname')){
    $this->data["users"] = $this->data["users"]->search('surname', $this->input->post('surname'));
}

$this->data["bla"]  = $this->data["users"]->get_all();

}

How do I figure out the total number of results? 如何计算结果总数? Thanks. 谢谢。

使用$this->data["users"]->count_all()进行行计数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM