Javascript 如何组合批次查询的结果集?

Javascript 如何组合批次查询的结果集?,javascript,php,quickbooks,Javascript,Php,Quickbooks,quickbooks API对于任何SQL查询只返回1000项,因此我需要成批查询。我的问题是,如何在php中将结果添加到一起 $customers = []; $start_position = 1; for ($i = 1; $i <= $number_of_queries; $i++) { $customers[$i] = $customer_service->query( $this->qb->context, $this-

quickbooks API对于任何SQL查询只返回1000项,因此我需要成批查询。我的问题是,如何在php中将结果添加到一起

$customers = [];
$start_position = 1;
for ($i = 1; $i <= $number_of_queries; $i++) {
    $customers[$i] = $customer_service->query(
        $this->qb->context,
        $this->qb->realm,
        "SELECT * FROM Customer STARTPOSITION " . $start_position . " MAXRESULTS 1000"
    );
    $start_position += 1000;
}

return json_encode($customers);
$customers=[];
$start_位置=1;
对于($i=1;$i查询(
$this->qb->context,
$this->qb->realm,
从客户起始位置“$start\U position.”选择*最大结果1000
);
$start_position+=1000;
}
返回json_encode($customers);
问题:如何将
$customers[1]
$customers[2]
$customers[3]
等组合到一个包含所有客户数据的数组中

或者,如果在客户端这样做更好,那么如何在JavaScript中这样做呢

我已经研究过了,但是如果密钥相同,这些解决方案就会覆盖

此外,我还研究了JavaScript。但是,我无法实现这一点

有没有人有过从批量查询中组合结果集的经验


您可以尝试使用PHP的
array\u merge()
函数

$customers = [];
$start_position = 1;
for ($i = 1; $i <= $number_of_queries; $i++) {
    $results = $customer_service->query(
        $this->qb->context,
        $this->qb->realm,
        "SELECT * FROM Customer STARTPOSITION " . $start_position . " MAXRESULTS 1000"
    );
    $start_position += 1000;
    $customers = array_merge($customers, results);
}

return json_encode($customers);
$customers=[];
$start_位置=1;
对于($i=1;$i查询(
$this->qb->context,
$this->qb->realm,
从客户起始位置“$start\U position.”选择*最大结果1000
);
$start_position+=1000;
$customers=array\u merge($customers,results);
}
返回json_encode($customers);

键看起来像什么?查询的结果是一个客户数组。每个客户都扩展到一个包含所有客户数据(几个不同键)的key
*\u data
对象。组成客户的是一个匿名对象数组吗?比如JSON中的
[{…},{…},{…}]
,还是更像
{customer_1:{..},customer_2:{..}
。简而言之,也许可以粘贴一个将在
$customers
arary中出现的值的示例。我想我们需要更多关于结构的详细信息,以建议如何合并结果集。@Cymen,我在将内容写入文件时遇到问题。我取而代之的是控制台的屏幕截图。请注意,该数组只有177个客户在这种情况下很长时间了,但我也能够用9000多个客户的结果测试代码。好吧,我会被诅咒的。很高兴为您服务!