|
本帖最后由 80后奔三ing 于 2012-5-3 11:34 编辑
同一条SQL语句,通过
$query_count = $this->db->query($sql_count)->num_rows();
得到的结果是 1
而直接在数据库里执行SQL语句得到的结果是2。
这是什么原因呀?
model里的代码如下:
$sql_count = "select count(*) from `employee` where `delete` = 0";
$sql = "select `id`,`department_id`,`employee_class_id`,`name`,`turename`,`phone`,`register` from `employee` where `id` <= (select `id` from `employee` order by `id` desc limit ".ceil($data['segment']) * $data['per_page'].") and `delete` = 0";
$query_count = $this->db->query($sql_count)->num_rows();
$query = $this->db->query($sql);
return $query->result_array();
我是想要做一个分页。。
|
|