3

您好我正在测试并尝试在关系表中插入一条记录,但没有成功。当我在联系人模块中保存时,我试图使用逻辑钩子在关系表中输入新行,但我得到的是空白 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();

        }
    }
    ?>
4

1 回答 1

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);
于 2013-03-05T09:52:52.930 回答