2013-04-16 112 views
0

心中已經SugarCRM的找機會做這個查詢基於帳戶名和名稱來尋找機會:的帳戶名和名稱

public function getOpportunity($session_id, $client, $email, $name){ 

     $acc = $this->getAccount($session_id, $client, $email); 
     $acc_id = $acc->entry_list[0]->id; 
     $query2 = " 
          opportunities.id in 
          (select accounts_opportunities.opportunity_id from 
          accounts_opportunities inner join 
          accounts where 
                accounts_opportunities.account_id = accounts.id and 
                accounts_opportunities.deleted = 0 and 
                accounts.deleted = 0 and 
                accounts.id = '{$acc_id}') 
          and opportunities.deleted=0 
          and opportunities.name = '{$name}'"; 

     $op = $client->get_entry_list($session_id, 'Opportunities', $query2); 

     return $op; 
    } 

出於某種原因,它返回我埃羅40訪問的錯誤否認。我不知道爲什麼這個查詢不起作用。我做了類似的工作,通過電子郵件查找帳戶,併成功將我想要的結果返回給我,而不會出現任何錯誤。該查詢如下:

public function getAccount($session_id, $client, $email){ 

     $query = "accounts.id in 
(select bean_id from 
email_addr_bean_rel inner join 
email_addresses where 
email_addr_bean_rel.email_address_id = email_addresses.id 
and email_addr_bean_rel.deleted = 0 and 
email_addresses.deleted = 0 and 
bean_module = 'Accounts' and 
email_addresses.email_address = '{$email}')"; 

     $acc = $client->get_entry_list($session_id, 'Accounts', $query); 
     return $acc; 
    } 

任何幫助,將不勝感激。謝謝。

編輯:我正在使用SOAP API和PHP。

回答

相關問題