CodeIgniter Forums
CI2.1.3 Limit bug? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: CI2.1.3 Limit bug? (/showthread.php?tid=56361)



CI2.1.3 Limit bug? - El Forum - 12-12-2012

[eluser]ladooboy[/eluser]
I've upgraded from CI2.0.2 to CI2.1.3 and noticed that all queries with an EMPTY string or FALSE value for limit would get a "limit 0" on the end of every query.

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

  if ($offset != '')
  {
   $this->ar_offset = (int) $offset;
  }

  return $this;
}

The reason is this line
Code:
$this->ar_limit = (int) $value;

If you pass FALSE or EMPTY STRING it will convert the $value to a 0 and limit every query to zero results. Same problem for offset.

I've removed the (int) conversion for LIMIT and OFFSET for now, which has fixed the issue.



CI2.1.3 Limit bug? - El Forum - 12-12-2012

[eluser]InsiteFX[/eluser]
It's not a bug you are suppose to be passing integer values to the limit cause.



CI2.1.3 Limit bug? - El Forum - 12-12-2012

[eluser]ladooboy[/eluser]
I was using it for counting results with where conditions.

I guess I can use this method from now on: $this->db->count_all_results();

Thanks for the reply.