CodeIgniter Forums
Oracle database drive bug with LIMIT - 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: Oracle database drive bug with LIMIT (/showthread.php?tid=57072)



Oracle database drive bug with LIMIT - El Forum - 02-12-2013

[eluser]North2Alaska[/eluser]
When I build a query with the Active Record and use the ->Limit(1), the result is never displayed. I displayed the sql and it looks like the Oracle drive is not correct. On line 775 of oci8_driver.php the line of code looks like this

Code:
$newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)";
Because rownum < $limit the value is not included. So if you use Limit(1) the row number with a rownum of 1 is not selected. To fix the bug, simply and an = (equal) so that it becomes <= (less than or equal to).

Code:
$newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum <= $limit)";



Oracle database drive bug with LIMIT - El Forum - 02-13-2013

[eluser]cpassas[/eluser]
If you think you've found a bug you might be better off posting it here:

https://github.com/EllisLab/CodeIgniter/issues/new