2013-04-16 83 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。

回答

相关问题