【发布时间】:2011-11-17 07:46:00
【问题描述】:
我使用活动记录,一切正常,但我想将 $data["totalres"] 设置为总结果,我的意思是,相同的查询但没有 LIMIT
问题是,当您执行查询修饰符时,前面的语句会被取消设置,所以我什至无法在得到结果后添加 $this->db->limit()。
有什么想法吗?我认为只是为了这样做而“复制”查询是一种不好的做法
function get_search($start, $numrows, $filter = array())
{
...
$this->db
->select("emp")
->from('emp')
->join('empr', 'empr.b = empr.id', 'left')
->like('code', $code)
->limit($numrows, $start);
...
$q = $this->db->get();
// number of rows WITHOUT the LIMIT X,Y filter
$data["totalres"] = ???????;
if ($q->num_rows() > 0)
{
$data["results"] = $q->result();
} else {
$data["results"] = array();
}
return $data;
}
【问题讨论】:
-
可能是这个stackoverflow.com/a/23648274/2664160 //忽略这个评论 he he
标签: php mysql codeigniter activerecord