im using active record, its all working ok but i want to set the $data["totalres"] to the total results, i mean, the same query but without the LIMIT
the problem is the previous statements gets unset when you do a query modifier, so i cant even add the $this->db->limit() after i get the results.
any ideas? i think its a bad practice to 'duplicate' the query just to do this
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;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…