如何处理“DataSet” PHP中的数据结构?

发布于 2024-10-25 10:30:50 字数 1017 浏览 0 评论 0原文

我正在尝试从 php.ini 调用肥皂网络服务。

Web 服务返回 ADO.NET DataSet 结构。 PHP 中有没有可以处理这种数据结构的库?如果有,它们叫什么?在哪里可以找到它们?如果没有,请随时提供提示吗?

到目前为止,我有这个(使用 ActiveMQ 和 NuSoap 库):

/**
 * Create a new service instance
 * Provide ActiveMQ uri and the extended class name
 **/
$client = new Client('tcp://localhost:61613?tcpNoDelay=false', 'test');

/**
 * New service reference
 **/
$service = new ServiceProxy($client, 'ServiceName');

/* Service call */
$result = $service->get_clients();

get_clients() 是一个执行实际服务调用并获取 DataSet 结构作为回报的方法。我怎样才能操纵这个返回值?

例如,在 .NET 中,有一个 DataSet 类。 ADO.NET DataSet 包含一个或多个 ADO.NET DataTable,而这些 DataTable 又由一个或多个在集合(数组)中返回的 ADO.NET DataColumn 和 DataRow 组成。

一个简单的代码示例(其中 DataSet 仅包含一个 DataTable)可以是:

/**
 * Here, the val variable will contain the data positioned in the 
 * first field of the first DataRow of the first DataTable 
 **/
string val = dataset.Table[0].Rows[0].ItemArray[0];

我想在 PHP 中执行相同的操作,但我需要帮助。

I'm trying to do a call to a soap webservice from php.

The webservice returns an ADO.NET DataSet structure. Are there any libraries in PHP that can deal with this sort of data structures? If so, what are they called and where can I find them? If not, feel free to give tips?

So far, I have this (using ActiveMQ and the NuSoap library):

/**
 * Create a new service instance
 * Provide ActiveMQ uri and the extended class name
 **/
$client = new Client('tcp://localhost:61613?tcpNoDelay=false', 'test');

/**
 * New service reference
 **/
$service = new ServiceProxy($client, 'ServiceName');

/* Service call */
$result = $service->get_clients();

get_clients() is a method that does the actual service call and it gets the DataSet structure in return. How can I manipulate this return value?

In .NET for example, there is a DataSet class. The ADO.NET DataSet contains one or more ADO.NET DataTables which in their turn consist out of one or more ADO.NET DataColumns and DataRows which are returned in a collection (array).

A simple code example, where the DataSet only contains one DataTable, can be:

/**
 * Here, the val variable will contain the data positioned in the 
 * first field of the first DataRow of the first DataTable 
 **/
string val = dataset.Table[0].Rows[0].ItemArray[0];

I want to do the same in PHP, but I need a helping hand.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜嗑 2024-11-01 10:30:50

我建议您尝试更多地了解您正在使用的数据的结构。它很可能是某种形式的 JSON 或 XML,可以通过大量 PHP xml 和 json 处理库进行操作。

您的第一步是查看请求返回的数据并确定其格式。 Microsoft 深入记录了 ADO.NET API 的数据集此处 在 MSDN 库中。这应该可以帮助您理解检查数据时所看到的内容。某些数据提供程序允许您以不同的格式访问相同的数据,具体取决于参数或一系列类似的函数。您有提供商 API 的文档吗?

接下来,在确定格式并破译数据集架构的细节之后,您需要一个类来操作数据。如果您正在处理符合已发布标准的内容,则可以使用 simpleXML、JSON 或 DOMXPath 之类的内容。此类应将数据存储在受保护的成员变量中,并提供检查、迭代、加载、刷新、搜索等方法。您应该在此处参考 PHP 手册的函数参考以获取帮助,并编写您需要的任何函数。我会一般性地编写它来处理任何类似的数据集并派生一个类以准确地公开特定应用程序所需的数据。

另一种方法是用 .net 语言编写 COM 组件来访问和操作数据,并通过 PHP 的 COM 扩展导入其函数。我想如果数据格式是一种奇怪的微软专有格式,我会选择这种选择。

第三种可能的方法仅在您具有对服务器的编程访问权限时才有效。如果您可以调整服务提供商以符合规范,Microsoft 已经发布了一个互操作性工具包,该工具包应该充当 .net 服务和 PHP 客户端之间的桥梁,使用代理对象层将 ado.net 数据公开给 PHP 脚本。他们经常使用 RESTful 这个词,但我不太确定他们的意思。在 Microsoft 互操作性总部此处查看 OData SDK for PHP(有有关 PHP 和其他 Microsoft 平台和产品(例如 Azure、silverlight、Bing 等)的信息请参见此处)。正如我所说,我认为您需要数据提供者发出符合其标准的数据。也许已经是这样了。没有模式我无法判断!如果是这样,那么这是您最好的选择。
祝你好运!

I would suggest you try learning more about the structure of the data you are working with. It is most likely some form of JSON or XML, which can be manipulated through the large set of PHP xml and json handling libraries.

Your first step is to look at the data being returned by your request and identifying it's format. Microsoft documents the ADO.NET API's datasets in depth HERE at the MSDN library. This should help you to make sense of what you are seeing when you inspect the data. Some data providers allow you to access the same data in different formats, depending on a parameter or a family of similar functions. Do you have documentation for your providers API?

Next, after you have identified the format and deciphered the specifics of the datasets schema, You need a class to manipulate the data. If you are dealing with something that conforms to a published standard you can use something like simpleXML, JSON or DOMXPath.This class should store the data in protected member variables and provide methods to inspect, iterate, load, refresh, search and so forth. You should refer to the PHP manual's function reference for help here and write whatever functions you need. I would write it generically to handle any similar dataset and derive a class to expose exactly the data I need for a particular application.

Another approach would be to write a COM component in a .net language to access and manipulate the data and import it's functions through PHP's COM extension. I think I would go with this choice if the data format is a weird proprietary Microsofty one.

The third possible approach works only if you have programming access to the server. If you can adapt the service provider to comply with the specification, Microsoft has released an interoperability toolkit which is supposed to act as a bridge between .net services and PHP clients using a layer of proxy objects to expose the ado.net data to PHP scripts. They throw the word RESTful around alot, but I'm not really sure what they mean by that. Check out the OData SDK for PHP HERE at Microsoft's interoperability HQ (there is info here about PHP and other Microsoft platforms and products like Azure, silverlight, Bing, etc., as well). As I said though, I think you would need the data provider to emit data which conforms to their standard. Perhaps it already does. I can't tell without a schema! If so then this is your best bet.
Good Luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文