Codeigniter with a NULL limit not working in the latest version of CI 2.1.2

I have the following get_authors_list function in one of my Codeigniter models

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 a call to 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 version 2.0.1 it does not work, to make it work, I needed to specify a restriction, as indicated in my function call

 $data['authors'] = $this->author_model->get_authors_list(50, 0) 

Specifying a NULL constraint doesn't work, why? Am I doing something wrong here? I correctly followed the instructions for updating Codeigniter, but I did not expect this side effect.

Any explanation is appreciated. Thanks!

+2
source share
2 answers

That's right, this will not work, because in the latest version of CodeIgniter in System/Database/DB_active_rec.php , they made changes to the line in the limit function of earlier versions:

 $this->ar_limit = $value; 

Now,

 $this->ar_limit = (int) $value; 

So, (int) null converted to 0 , and you are not getting any results .

So, I think you need to completely remove the limit call. Why do you need to set it to null anyway?

+4
source

It doesn't work anymore. A change has been made to the source code, which now ignores the NULL value. See commit .

+3
source

All Articles