$this->db->limit() working differently? |
Hi
I had to fix an application while upgrading from version 3.1.0 to 3.1.2 because active record $this->db->limit() apparently works differently: Code: Code: $this->db->limit(0,1); produced under system 3.1.0: Code: SELECT * FROM `settings produced under system 3.1.2: Code: SELECT * FROM `settings` LIMIT 1, 0 I couldn't find this in the change log. Thanks.
The limit and offset were reversed from mysql, see it below and in the Users Guide.
As far as I remember it has always been this way back to version 1.6x PHP Code: $this->db->limit(10, 20); // Produces: LIMIT 20, 10 (in MySQL. Other databases have slightly different syntax) What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
MySQL data fetch query as limit and offset. You can use this code for limit query
function getRecords($searchData) { $search_index = '2'; $limit = "10"; $this->db->limit($limit,$search_index); $this->db->where('status','Active'); $this->db->order_by($this->table.'.add_date', 'desc'); $this->db->where('approve_status','Approved'); $this->db->where('type','Blog'); $query = $this->db->get($this->table); $result = $query->result(); return $result; } |
Welcome Guest, Not a member yet? Register Sign In |