SugarCRM - 在关系表中插入新记录

时间:2013-03-04 12:30:27

标签: sugarcrm

您好我正在测试并尝试在关系表中插入记录但没有成功。我正在尝试使用逻辑挂钩在关系表中输入新行,当我在联系人模块中保存但不是我得到空白的index.php页面。 问题出在哪儿? 谢谢

 <?php

    include_once('modules/Contacts/ContactOpportunityRelationship.php');
    class User_hook {

        function insert()
        {
            $instance=new ContactOpportunityRelationship();
            $instance->$contact_id='96163e07-f55a-eb87-251f-513482e4a1da';
            $instance->$opportunity_id='c99178c5-fed5-7092-4a79-4e1da40a1eea';
            $instance->save();

        }
    }
    ?>

1 个答案:

答案 0 :(得分:7)

正确的语法应该是

<?php
$contactId = '96163e07-f55a-eb87-251f-513482e4a1da';
$oppId = 'c99178c5-fed5-7092-4a79-4e1da40a1eea';
$oContact = BeanFactory::getBean('Contacts', $contactId);
$oContact->load_relationship('opportunities');
$oContact->opportunities->add($oppId);