QuickBooks php DevKit 数据库查询仅返回 100 行

QuickBooks php DevKit database query only returning 100 rows

我正在尝试使用 DevKit 浏览我的 QuickBooks Online 帐户中的所有现有客户,并更新每个客户的显示名称,以便在他们的公司名称前加上我分配给他们的公司 ID。目前,账户中大约有1800个客户。

使用下面的代码,每次我 运行 脚本时我都可以成功地处理 100 个客户,但它会在此时停止。服务客户查询对行 return 是否有时间或数量限制?如果是这样,有没有办法增加它?或者完全是其他问题?

Quickbooks_update:

class Quickbooks_Update extends CI_Controller
{
    function quickbooks_add(){
        require_once 'application/QuickBooks/config.php';
        $this->load->model('companyAccounts');
        $success = array();
        $failed = array();
        $duplicate = array();
        $not_exist = array();

        $CustomerService = new QuickBooks_IPP_Service_Customer();

        $customers = $CustomerService->query($Context, $realm, "SELECT * FROM Customer ");

        foreach($customers as $customer) {

            $name = $customer->getCompanyName();

            $q = $this->db->select('companyAccountId');
            $q = $this->db->from('companyAccounts');
            $q = $this->db->where('companyName', $name);
            $q = $this->db->get();
            $results = $q->result();

            foreach($results as $company){
                $companyId = $company->companyAccountId;
            }
            if(sizeof($results) == 1){
                $customer->setDisplayName($companyId . '-' . $name);
                $resp = $CustomerService->update($Context, $realm, $customer->getId(), $customer);
                if(!$resp){
                    array_push($failed, $name);
                }else{
                    array_push($success, $name);
                }
            }
            else if(sizeof($results) == 0){
               array_push($not_exist, $name);
            }
            else{
                array_push($duplicate, $name);
            }
        }
        $data['success'] = $success;
        $data['failed'] = $failed;
        $data['duplicate'] = $duplicate;
        $data['not_exist'] = $not_exist;
        $this->load->view('quickbooks', $data);
    }
}

谢谢!

QuickBooks Online 默认情况下一次只能 returns 100 行。

如果您参考文档:

https://developer.intuit.com/docs/0100_accounting/0300_developer_guides/querying_data

您会找到大量示例,说明如何使用 STARTPOSITIONMAXRESULTS 来控制返回的记录数:

SELECT * FROM Invoice WHERE Status = 'Synchronized'STARTPOSITION 1 MAXRESULTS 10

SELECT * FROM Invoice WHERE Status = 'Synchronized'STARTPOSITION 11 MAXRESULTS 10

引用文档:

To page through the results, specify STARTPOSITION (position of the entity in the query results) and MAXRESULTS (maximum number of entities in the result).

并且:

The maximum number of entities that can be returned in a response is 1000. If the result size is not specified, the default number is 100. If a query returns many entities, fetch the entities in chunks, as described in Pagination. To determine the number of entities that a particular query returns, probe by using the COUNT keyword in the query. See Count for details.