首页 > 解决方案 > getItems 中的行数

问题描述

我试图使用 phpSPO 库从列表中获取所有项目:https ://github.com/vgrem/phpSPO

但是,在 Data 数组的 $remoteList 属性中,只有 100 行,并且列表有 100 多个项目。我看到这是一个常见问题,但是我不知道我应该为这个库考虑哪种解决方案。 https://sharepoint.stackexchange.com/questions/74777/list-api-get-all-items-limited-to-100-rows

$remoteList = $web->getLists()->getByTitle(xxx)
$listData = $remoteList->getItems();

标签: phpsharepoint

解决方案


此文件中定义的CamlQuery类有一个公共属性:ListItemCollectionPosition

https://github.com/vgrem/phpSPO/blob/b05be0eba6902dabd18784576bb6e1d55426fa99/src/SharePoint/CamlQuery.php

这需要一个ListItemCollectionPosition对象作为一个值:https ://github.com/vgrem/phpSPO/blob/b05be0eba6902dabd18784576bb6e1d55426fa99/src/SharePoint/ListItemCollectionPosition.php

所以我认为你的代码需要看起来像:

$remoteList = $web->getLists()->getByTitle(xxx);

$listItemCollectionPosition = new new ListItemCollectionPosition(); // Either add a use statement for this or use the fully qualified class name here
// ... (set the values according to the items/page you require)
$remoteList->ListItemCollectionPosition = $listItemCollectionPosition;

$listData = $remoteList->getItems();

关于如何准确使用它,请阅读此处的信息:

https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ee534956(v%3Doffice.14)#retrieving-items-using-list-item-collection-position

该示例使用 C# 编写,但并不难理解。

看起来好像您ListItemCollectionPosition在查询上设置了以获取后续“页面”。看起来响应ListItemCollectionPosition本身也包含一个属性,然后您可以将其用作下一个请求的起点。


推荐阅读