incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Hodgson <hodgson_...@hotmail.com>
Subject Pagination
Date Tue, 27 Nov 2012 19:19:38 GMT

Hi All,
Wondering if anyone has any good solutions to pagination? In particular enumerating the number
of pages and linking to each page, a common feature in forums.
This code is untested (using phpcassa) and may need tweaking to get the correct range of records
or maybe completely wrong! however it shows the concept of taking a page number then pulling
out a range of posts belonging to that page:
$cf_threads looks like:thread_ID => (timestamp => post_id)
if($page > 1)        {        $ranger = ($pagenumber * 20);        $low_ranger = $ranger
- 20;        $arr_range = $cf_threads->get("$thread_id" , $columns=null ,  $column_start=""
, $column_finish="" , $column_reversed=True, $limit=$ranger);        $arr_page = array_slice($arr_range,
$low_ranger , $ranger , TRUE);        }else                {                $arr_page = $cf_threads->get("$thread_id"
, $columns=null ,  $column_start="" , $column_finish="" , $column_reversed=True, $limit=20);
               }
I think this should be ok? the only concern is if there are some really long threads when
im having to pull the entire CF.
Another idea involved a schema change and using a super CF to include a page number as follows:
Thread_ID => (PageNumber(timestamp => Post_ID))
Probably more efficient but generally page numbers go backwards ie page 1 has newest content
so this would complicate things when writing data and cause load if logic was included to
reorganise page numbers etc.
Cheers
Samhttp://Newsarc.net 		 	   		  
Mime
View raw message