tibberous Posted February 28, 2010 Share Posted February 28, 2010 You learn something new everyday: http://www.arraystudio.com/as-workshop/mysql-get-total-number-of-rows-when-using-limit.html Basically, rather than having to do a query twice, you can do it once, then do a second query to get the amount of total results. Not only is it better performance wise, but you don't need to have conditions in 2 places (and it avoids the bug where the queries are out of sync, and you'll have like 8 pages but only 2 real pages of results) Quote Link to comment https://forums.phpfreaks.com/topic/193703-the-right-way-to-do-pagination/ Share on other sites More sharing options...
xylex Posted March 1, 2010 Share Posted March 1, 2010 One query doesn't mean that it's faster than two. http://www.mysqlperformanceblog.com/2007/08/28/to-sql_calc_found_rows-or-not-to-sql_calc_found_rows/ Quote Link to comment https://forums.phpfreaks.com/topic/193703-the-right-way-to-do-pagination/#findComment-1019701 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.