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 !
It doesn't work anymore. There's been a change in the source code that will now ignore
NULL
value. See this commit.Right, it won't work because, in the latest version of CodeIgniter in their
System/Database/DB_active_rec.php
file, they made a change to a line inlimit
function of earlier versions:is now,
So,
(int) null
is being converted to0
, and, you are not getting any results.So I think you have to remove the
limit
call totally. Why do you need to set it tonull
anyway?