处理从Web服务返回到数据库的大型数据块

时间:2012-10-25 07:27:50

标签: php mysql soap

我很难处理Web服务变大时返回的数据。 我使用NuSOAP PHP库来实现这一目的,当服务返回的数据很小时,一切顺利,但是当它变大时,我的内部服务器错误达到500.

我所做的就是使用NuSOAP来检索自己将结果解析为数组的数据,然后迭代这个数组以将数据导入到本地DDBB中。没有什么花哨。 它可以得到的最大值是1000个结果,因为服务中有一个分页选项参数,它将限制每个调用的参数....但是在800个记录之后我就达到了错误。

我试图增加init集中的内存并增加执行时间限制但没有成功。

我的猜测是问题是数据的频率与php解析数据的频率不同。解决方案?也许缓冲区可以在这种情况下正常工作,但不知道如何在PHP中实现这一点。有什么想法吗?

以下是代码:

$client = new nusoap_client($WSDL);
do {
    $data = $client->call($serviceName, array('GetValuesFrom' => $getValuesFrom,'PW'            => $pw, 'StartIndex' => $startIndex, 'Count' => $count), $ns, $ns);

    // Check there if there are results at all
    if(!$data) {
        $message .= 'No results returned by the service<br>';
    break;
    }

    // Script that imports it to the DDBB       
    require_once('import_into_DDBB.php');

    $pulledData = count($data);
    $totalProcessed += $pulledData;
    $startIndex++;  
}
while($count == $pulledData);

0 个答案:

没有答案
相关问题