dcramer / wp-lifestream

Lifestreaming plugin for Wordpress
http://forums.lifestrm.com/index.php
122 stars 31 forks source link

Problem with "SELECT ... LIMIT $start, $end" syntax in Lifestream::options_page() #41

Open tonyduckles opened 14 years ago

tonyduckles commented 14 years ago

While browsing around some of the pages in the Lifestream admin section (e.g. Events, Errors), I noticed that the pagination was wonky: every time I went a page deeper, the number of items on the page grew.

I think I traced the problem back to Lifestream::options_page(). Several of the SQL queries here are using the "SELECT ... LIMIT $start, $end" syntax, e.g. "1,50" for the first page, "50,100" for the next page, and so on. In other words, the first parameter is the lower-bound and the second parameter is the upper-bound. According to the MySQL docs (http://dev.mysql.com/doc/refman/5.0/en/select.html), the syntax for the LIMIT clause in the SELECT statement is "[offset], [row_count]", in other words "$start, NUM_THINGS_PER_PAGE". I tweaked the code on my install and sure enough it fixed the problem.

Was this maybe just a simple oversight? Or is this maybe a portability thing, e.g. that the "SELECT ... LIMIT ..." syntax is different across different RDBMS platforms (wince)?

I can whip together a patch quick, if you'd like.

Thanks!