Php 不骑自行车时做
Php Do-While not cycling
我有这部分代码用于检查文件是否可以从 Ebay Large Merchant Service 下载
$retry = 0;
do {
if ($retry > 0){sleep(5);}
$response = $session->sendBulkDataExchangeRequest('getJobStatus',$getJobStatusRequestXml);
$xml = simplexml_load_string($response);
if(!empty($xml) && 'Success' == (string)$xml->ack)
{
$jobStatus = (string)$xml->jobProfile->jobStatus;
$completionTime = (string)$xml->jobProfile->completionTime;
$percentComplete = (string)$xml->jobProfile->percentComplete;
$fileReferenceId = (string)$xml->jobProfile->fileReferenceId;
$taskReferenceId = (string)$xml->jobProfile->jobId;
}
$retry++;
} while ($jobStatus == 'Completed' || $retry >=10);
...其他下载文件的功能...
发送BulkDataExchangeRequest 并API 调用以检查jobStatus。
我需要重复此调用直到 jobStatus 完成或(跳过无限循环)如果重试 => 10 但它不起作用并尝试下载文件(do-while 后的下一个函数)如果 jobStatus 是进行中或预定。
我哪里错了?
您的 while 条件是错误的 - 这将继续 'while' 状态已完成或重试 >= 10。
你可能想要
while ($jobStatus != 'Completed' && $retry <10);
表示在作业未完成且重试次数小于 10 时重复。
我有这部分代码用于检查文件是否可以从 Ebay Large Merchant Service 下载
$retry = 0;
do {
if ($retry > 0){sleep(5);}
$response = $session->sendBulkDataExchangeRequest('getJobStatus',$getJobStatusRequestXml);
$xml = simplexml_load_string($response);
if(!empty($xml) && 'Success' == (string)$xml->ack)
{
$jobStatus = (string)$xml->jobProfile->jobStatus;
$completionTime = (string)$xml->jobProfile->completionTime;
$percentComplete = (string)$xml->jobProfile->percentComplete;
$fileReferenceId = (string)$xml->jobProfile->fileReferenceId;
$taskReferenceId = (string)$xml->jobProfile->jobId;
}
$retry++;
} while ($jobStatus == 'Completed' || $retry >=10);
...其他下载文件的功能...
发送BulkDataExchangeRequest 并API 调用以检查jobStatus。
我需要重复此调用直到 jobStatus 完成或(跳过无限循环)如果重试 => 10 但它不起作用并尝试下载文件(do-while 后的下一个函数)如果 jobStatus 是进行中或预定。
我哪里错了?
您的 while 条件是错误的 - 这将继续 'while' 状态已完成或重试 >= 10。
你可能想要
while ($jobStatus != 'Completed' && $retry <10);
表示在作业未完成且重试次数小于 10 时重复。