Help with Prefetching Next Record in DB - 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: Help with Prefetching Next Record in DB (/showthread.php?tid=37482) |
Help with Prefetching Next Record in DB - El Forum - 01-11-2011 [eluser]Unknown[/eluser] Hi all, I'm new to CodeIgniter and need some help with pre-fetching the next record in database from a result. Essentially it's a list of destinations, I need to pre-fetch the next destination in the list. Is there an easy way to do this? My current model contains: Code: class Times_model extends Model{ Any and all help is appreciated. PS Help with Prefetching Next Record in DB - El Forum - 01-11-2011 [eluser]Cristian Gilè[/eluser] Hi PurpleSmurf, you can achieve this using $limit and $offset. Set $limit to 1 (you want only the next one record) and change $offset value during the fetch operation. For example in your controller: Code: $this->load->model('times_model'); In your model change the get_records function to return a single row: Code: function get_records($limit, $offset){ Cristian Gilè Help with Prefetching Next Record in DB - El Forum - 01-11-2011 [eluser]pickupman[/eluser] I used something like this before (similar to links at the bottom of the page for the forums. The part I don't like about my solution is having to return the query resource and not the result object. Code: //In model Help with Prefetching Next Record in DB - El Forum - 01-11-2011 [eluser]Unknown[/eluser] Awesome! Thanks guys, much appreciated. PS |