Pagination on AZURE Table service with FILTER

Actually azure table query will return 1000 records at maximum. We can get the next 1000 record based on token keys ($result->getNextPartitionKey() and $result->getNextRowKey). But the current Azure-php-sdk is not supporting for $result->setNextPartitionKey(). To make it work you need to update you SDK, look at here.

I have tried by another way of doing it by using rowKey. We can use just less-than and greater-than condition in the table service query to do get the pagination result as we need. The bellow will give 1000 records per page without get/set nextrowkey.




$nextRowKey=NULL;
$preRowKey=NULL;

if(isset($_REQUEST['nrk']))
{
 $nextRowKey=$_REQUEST['nrk'];
}
else if(isset($_REQUEST['prk']))
{
 $preRowKey=$_REQUEST['prk'];
}
$result=FriendsListPage();
$options = new QueryEntitiesOptions();

if($nextRowKey)
{
 $filter = "PartitionKey eq 'XXXX' and RowKey gt '$nextRowKey' ";
}
else if($preRowKey)
{
 $filter = "PartitionKey eq 'XXXX' and RowKey lt '$preRowKey' ";
}
else
{
 $filter = "PartitionKey eq 'XXXX'";
}
//apply filter here
$options->setFilter(Filter::applyQueryString($filter));
$result = $tableRestProxy->queryEntities("tablename", $options);
if($result)
{
$nextPartitionKey = $result->getNextPartitionKey();
$nextRowKey = $result->getNextRowKey();
//next rowkey
$output['NRK']=NULL;
//previous row key
$output['PRK']=NULL;

$output['entities']=NULL;
$obj_result=$result->getEntities();

foreach($obj_result as $key=>$value)
{
 $output['entities'][$key]['PartitionKey'] = $value->getPropertyValue("PartitionKey");
 $output['entities'][$key]['RowKey'] = $value->getPropertyValue("RowKey");
}
if($obj_result)
{
 $output['PRK']=$obj_result[0]->getPropertyValue("RowKey");
 $output['NRK']=$value->getPropertyValue("RowKey");
}
print_r($output);
}