Kalessin
02-14-2006, 08:30 AM
I have a bunch of internal office memos in a database, which I retrieve using:
$all_memos=mysql_query("SELECT * FROM memos WHERE (visible='yes' AND date>'$inc_date') ORDER BY date DESC");
This, obviously, returns all memos within a specified time frame and sorts them by date order.
I would like to use LIMIT to split the contents over multiple pages to speed things up, but my problem is that the memos can be edited after they've been written. This means that the date will become more recent, whilst the memo record's unique ID (primary key) will remain the same.
Thus, I need to perform a LIMIT on records which have already been sorted by date, otherwise the first page may theoretically omit the most recent memos.
Do I need to use more than one SELECT, or would it be quicker to retrieve all results, then sort them in PHP?
Thanks,
Kal
$all_memos=mysql_query("SELECT * FROM memos WHERE (visible='yes' AND date>'$inc_date') ORDER BY date DESC");
This, obviously, returns all memos within a specified time frame and sorts them by date order.
I would like to use LIMIT to split the contents over multiple pages to speed things up, but my problem is that the memos can be edited after they've been written. This means that the date will become more recent, whilst the memo record's unique ID (primary key) will remain the same.
Thus, I need to perform a LIMIT on records which have already been sorted by date, otherwise the first page may theoretically omit the most recent memos.
Do I need to use more than one SELECT, or would it be quicker to retrieve all results, then sort them in PHP?
Thanks,
Kal