MSSQL offset workaround - 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: MSSQL offset workaround (/showthread.php?tid=16036) |
MSSQL offset workaround - El Forum - 02-23-2009 [eluser]faceh[/eluser] I have found a few topics on this forum regarding MSSQL pagination, but didn't find anybody listing the following as a workaround. Looking at the limit() method for the mssql driver, Codeigniter takes your db->limit($limit, $offset) call and converts it to limit($limit + $offset) with no offset. So, my workaround is to use array_slice() to chop off and return the end of the array, starting from the $offset. Is this a terrible way to do things? I can see it being a bit slow with databases with 1000s of records as you are working with huge arrays, but from what I can see of the other SQL query hacks for MSSQL pagination, they dont look too pretty/efficient either... Example: Code: // Set the offset / limit MSSQL offset workaround - El Forum - 03-01-2009 [eluser]whobutsb[/eluser] I can see myself using this for returning row ID numbers and doing a loop foreach of the ID numbers to get that actual data. But I wouldn't want to return 1000's of rows with lots of data in them. |