使用SugarCRM Beans检索数据

时间:2014-04-11 15:06:17

标签: sugarcrm sugarbean

我需要将此SQL查询转换为bean格式。

"SELECT first_name, last_name FROM leads INNER JOIN  contacts_leads_1_c  ON 
leads.id=contacts_leads_1_c.contacts_leads_1leads_idb  where 
contacts_leads_1_c.contacts_leads_1contacts_ida='".$bean->id."'";

我已经有了这个

$lead = new Lead();
$where = "contacts_leads_1_c.contacts_leads_1contacts_ida = '$bean->id' ";
$lead_list = $lead->get_full_list("", $where,true);
$all_leads = array();
foreach($all_leads as $leads){
$bean->contacts_leads = $ref->first_name . ',' . $ref->last_name;

这是问题

$lead_list = $lead->get_full_list("", $where,true);

提前致谢,

1 个答案:

答案 0 :(得分:3)

如果$ bean已经是联系人,您可以获取相关字段的列表:

$leads = $bean->get_linked_beans('FIELDNAME','Leads');

FIELDNAME可以在vardefs中找到,而不是关系名称,它是定义链接的字段的名称。

注意:在您的示例中,您将创建一个空数组,然后循环遍历它。