douqian6315 2016-08-08 13:07
浏览 36

如何在azure表php中检索超过1000行

I am trying to get more than 1000 rows from azure in php. First of all i am not able to use filter class. which namespace need to be added to use filter class after that while loop is gng in infinite loop any help

$tableRestProxy = ServicesBuilder::getInstance()->createTableService($this->connectionString); $filter = "( PartitionKey eq '$id' )";

$options = new QueryEntitiesOptions();
$options->setFilter(Filter::applyQueryString($filter));

$result = $tableRestProxy->queryEntities('test', $options);
$entities = $result->getEntities();

$nextPartitionKey = $result->getNextPartitionKey();
$nextRowKey = $result->getNextRowKey();

while (!is_null($nextRowKey) && !is_null($nextPartitionKey) ) {

    $options = new QueryEntitiesOptions();
    $options->setNextPartitionKey($nextPartitionKey);
    $options->setNextRowKey($nextRowKey);
    $options->setFilter(Filter::applyQueryString($filter));

    $result2 = $tableRestProxy->queryEntities("test", $options);
    $newentities = $result2->getEntities();
    $entities=array_merge($newentities, $entities);    

}

link m using is PHP - Azure Table Storage in with more than 1000 entities

  • 写回答

1条回答 默认 最新

  • dongquxiao8545 2016-08-09 06:36
    关注

    You can leverage setTop() function of MicrosoftAzure\Storage\Table\Models\QueryEntitiesOptions class to select the top X (number) entities of the table.

    And according the description at https://github.com/Azure/azure-storage-php/blob/master/src/Table/Models/QueryEntitiesOptions.php#L148, we can find that the filter classes have moved into the namespace MicrosoftAzure\Storage\Table\Models\Filters

    If you want to use the filter classes in the new Azure Storage SDK for PHP, you can try to include the package as:

    use MicrosoftAzure\Storage\Table\Models\Filters\QueryStringFilter;
    

    Please consider the following code snippet:

    use MicrosoftAzure\Storage\Table\Models\QueryEntitiesOptions;
    use MicrosoftAzure\Storage\Table\Models\Filters\QueryStringFilter;
    $options = new QueryEntitiesOptions();
    $filter = new QueryStringFilter("(RowKey eq '".$id."')");
    $options->setFilter($filter);
    $options->setTop(1000);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序