Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
silverstripe RestfulServer模块-获取具有所有属性的相关记录_Rest_Content Management System_Silverstripe - Fatal编程技术网

silverstripe RestfulServer模块-获取具有所有属性的相关记录

silverstripe RestfulServer模块-获取具有所有属性的相关记录,rest,content-management-system,silverstripe,Rest,Content Management System,Silverstripe,我使用Restful服务器模块执行以下操作: GET/api/v1/(ClassName)?(字段)=(Val)和(字段)=(Val)-搜索匹配的数据库记录 api应获取与特定产品相关的所有图像的URL,如下所示: 不幸的是,返回的XML没有显示ProductImages的完整信息。只有属性href和id。 这里是xml: <?xml version="1.0" encoding="UTF-8"?> <ArrayList totalSize="1"> <Produ

我使用Restful服务器模块执行以下操作:

GET/api/v1/(ClassName)?(字段)=(Val)和(字段)=(Val)
-搜索匹配的数据库记录

api应获取与特定产品相关的所有图像的URL,如下所示:

不幸的是,返回的XML没有显示ProductImages的完整信息。只有属性href和id。 这里是xml:

<?xml version="1.0" encoding="UTF-8"?>
<ArrayList totalSize="1">
<Product href="http://domain.com/api/v1/Product/9.xml">
<ArticleID>myID</ArticleID>
<ID>9</ID>
<ProductImages linktype="has_many" href="http://domain.com/api/v1/Product/9/ProductImages.xml">
<ProductImage href="http://domain.com/api/v1/ProductImage/265.xml" id="265"/>
<ProductImage href="http://domain.com/api/v1/ProductImage/268.xml" id="268"/>
<ProductImage href="http://domain.com/api/v1/ProductImage/271.xml" id="271"/>
</ProductImages>
</Product>
</ArrayList>

我使用curl加载URL。 在最坏的情况下,我认为我必须从XML中获取ProductImage URL(例如),并执行多个调用

许多thx需要任何帮助,
florian

您需要增加
RestfulServer
内部的
关系深度。您可以通过传入
relationdepth
querystring参数来实现这一点


另一方面,它这样工作的原因是通过不必实例化所有图像对象来保持服务器上的低负载。这也意味着带宽稍微低一些。

状态:我现在正在打多个电话。但这似乎是一个缓慢的解决方案:(嗨!relationdepth没有帮助。我认为需要显示更深层的关系。在我的例子中,ProductImages已经显示了,但仍然只有id和href属性。还有更多。目前,我可以通过向产品中添加公共getter函数来帮助自己。如下所述:例如,我添加了一个公共getter,它可以ns是一个逗号分隔的字符串,包含所有相关的ProductImage URL。工作正常。