我写了以下查询:
var account_query = "accounts.id IN ( SELECT account_id FROM accounts_contacts WHERE contact_id='"+ id +"')";
id是联系人ID
请给我解决方案..答案 0 :(得分:0)
您可以这样做:
此示例是加载联系人并获取其父帐户:
//Load Contact
$bean = BeanFactory::getBean('Contacts', $id);
//If relationship is loaded
if ($bean->load_relationship('accounts'))
{
//Fetch related beans
$relatedBeans = $bean->accounts->getBeans();
$parentBean = false;
if (!empty($relatedBeans))
{
//order the results
reset($relatedBeans);
//first record in the list is the parent
$parentBean = current($relatedBeans);
}
}