Welcome Guest, Not a member yet? Register   Sign In
LIMIT 0
#1

[eluser]thomasz[/eluser]
I have a db call using db->select, db->where, db->order_by and finally db->get(table) that for some reason is including a LIMIT 0 in the actual query produced. I have been using CodeIgniter for over 3 years and am currently on the latest version (2.1.0). I have never run into this problem and I'm not sure what is causing it now.

I traced through the code and found that at DB_active_rec line 1792 the code is
Code:
if (is_numeric($this->ar_limit))
In this situation ar_limit had a value of 0. I cannot figure how this was set! To try and fix I perfromed an explicit $db->close() after the prior db call but this didn't help.

Long story short in my model I added this line before db->get:
Code:
$this->db->ar_limit = null;

This fixed the problem. Again, I haven't had to do this anywhere else and the code base is getting pretty big so I'm not sure what was causing it in this particular location. I've worked around here but I'm worried this may be happening in other places that I just haven't found yet.
#2

[eluser]Unknown[/eluser]
Hi,
I tried your solution who's not working for me.

this iswhat i did in DB_active_rec.php

Code:
public function limit($value, $offset = '')
{
  $this->ar_limit = (!empty($value)) ? (int) $value : '';

  if ($offset != '')
  {
   $this->ar_offset = (!empty($offset)) ? (int) $offset : '';
  }
  return $this;
}
#3

[eluser]thomasz[/eluser]
This happened to me again and my solution didn't work here either (now I'm wondering why it did the first time). This is definitely a bug in CodeIgniter. Julien thank you for you code this did work in both cases. I am worried though about modifying the CI code since it will get overwritten next release.
#4

[eluser]skunkbad[/eluser]
Are you working with pagination, because I had somebody tell me that my pagination was producing the limit 0. As a result, I just modified my query so that it was never possible. If you look at the issues and commits for Community Auth, you will see what I did. The strange thing is that I never saw this issue, so I was wondering if it only applies to certain servers or browsers.




Theme © iAndrew 2016 - Forum software by © MyBB