Welcome Guest, Not a member yet? Register   Sign In
Pagination on Random Result Set ?
#4

[eluser]sophistry[/eluser]
I've been thinking about this more... array_multisort is not going to help - I was thinking you had a different issue.

You have to have a well-thought-out and sensible design when you've got a query returning random records (a subset of the whole set I assume) and a limit clause in effect for pagination. Basically, if you want to keep the same result set you can't use LIMIT and random results at the same time. That is because if you LIMIT a random recordset and you do a new query for the next page, you'll never have the same set again. So, you can't LIMIT and get random recordsets at the same time - it just won't work.

You have to return the whole recordset once, store it and then do your limiting and paging off the temporary stored recordset. So, make a SESSION var hold the whole set or build a db table (better) to hold the recordset (which you can then LIMIT in subsequent requests). If you build a db table you can also set ordering values in a field and then do ORDER BY.

Looking around the net I found this little MYSQL fragment (you can order by field and set the custom sort order):
select * from pet order by field(species, 'cat', 'dog', 'bird');

I'll keep that trick in my back pocket should I need it...

There was some shakeout when the CI website was re-launched. all usernames got ci_ prepended or appended (can't remember which). So, you had to login with ci attached to your username the first time.


Messages In This Thread
Pagination on Random Result Set ? - by El Forum - 07-09-2007, 12:50 PM
Pagination on Random Result Set ? - by El Forum - 07-09-2007, 03:27 PM
Pagination on Random Result Set ? - by El Forum - 07-10-2007, 11:32 AM
Pagination on Random Result Set ? - by El Forum - 07-10-2007, 12:30 PM
Pagination on Random Result Set ? - by El Forum - 07-11-2007, 04:09 PM
Pagination on Random Result Set ? - by El Forum - 07-11-2007, 08:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB