2015-06-12 21 views
0

我想使用DevKit通过我的QuickBooks Online帐户中的所有现有客户并更新其中每个人的显示名称以将公司名称与公司ID一起已经分配给他们。目前,该帐户中约有1800位客户。QuickBooks php DevKit数据库查询只返回100行

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

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); 
    } 
} 

谢谢!

回答

2

QuickBooks默认情况下,一次只能返回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

要引用文档:

要遍历结果,请指定STARTPOSITION(实体在查询结果中的位置)和MAXRESULTS(结果中实体的最大数量)。

和:

可在响应中返回实体的最大数量为1000如果未指定结果大小,缺省数为100如果查询返回的许多实体,如分页中所述,以块的形式提取实体。要确定特定查询返回的实体数量,请在查询中使用COUNT关键字进行探测。详情请参阅计数。