0

我已完成此查询以根据帐户名称和名称寻找机会:

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。

4

1 回答 1

0

有关更多详细信息,请参阅此博客文章...

http://developers.sugarcrm.com/wordpress/2012/03/19/howto-avoiding-subqueries-with-our-web-services/

于 2013-04-17T19:50:24.630 回答