I have following get_authors_list function in one of my Codeigniter model
function get_authors_list($limit,$offset){
$data = array();
$this->db->select('*')->from('authors')->limit($limit,$offset)->order_by('id','desc');
$query = $this->db->get();
if ($query-> num_rows() > 0){
$data = $query->result_array();
}
return $data;
$q->free_result();
}
Before upgrading to Codeigniter 2.1.2, I used call this method from my controller as
$data['authors'] = $this->author_model->get_authors_list(NULL, 0)
and it worked as expected but after upgrading to codeigniter version 2.1.2 it doesn’t work, to get it working I had to specify limit as follows in my function call
$data['authors'] = $this->author_model->get_authors_list(50, 0)
That’s specifying limit to NULL is not working, why? Am I doing anything wrong here?
I followed Codeigniter’s upgrade instruction correctly but it’s some side effect I didn’t expect.
Any explanation is welcome.
Thanks !
Right, it won’t work because, in the latest version of CodeIgniter in their
System/Database/DB_active_rec.phpfile, they made a change to a line inlimitfunction of earlier versions:is now,
So,
(int) nullis being converted to0, and, you are not getting any results.So I think you have to remove the
limitcall totally. Why do you need to set it tonullanyway?