2014-03-31 59 views
0

我有以下查詢要在聯繫人模塊中實現。自定義列表查看聯繫人模塊中的查詢

SELECT DISTINCT bean_id FROM `email_addr_bean_rel` as a, 
(select S.email_address_id from contacts R 
INNER JOIN email_addr_bean_rel S ON R.id = S.bean_id 
and S.bean_module='contacts' and S.deleted=0 
group by S.email_address_id 
having count(S.email_address_id)>1) as Dup 
where Dup.email_address_id=a.email_address_id 
and a.bean_module='contacts' and a.deleted=0 

我怎樣custom_from,custom_select實現這個或custom_where

回答

0

量變到質變的查詢的WHERE子句是很容易的,但如果你想改變選擇和這是一個更大的問題。

兩種方式來實現這一目標是:

1)創建一個Contact.php create_new_list_query()函數(模塊核心類)

function create_new_list_query() 
{  

    $return_array = Array(); 

    $return_array['select'] = "SELECT DISTINCT bean_id "; 
    $return_array['from'] = " FROM `email_addr_bean_rel` as a, (select .email_address_id from contacts R INNER JOIN email_addr_bean_rel S ON R.id = S.bean_id and S.bean_module='contacts' and S.deleted=0 group by S.email_address_id having count(S.email_address_id)>1) as Dup ";        
    $return_array['where'] = " where Dup.email_address_id=a.email_address_id and a.bean_module='contacts' and a.deleted=0 ";  
    $return_array['order_by'] = ""; 

    return $return_array['select'] . $return_array['from'] . $return_array['where']. $return_array['order_by']; 

} 

您可以將它們添加到選擇的顯示領域select和listviewdefs.php

$listViewDefs ['Contacts'] = 
    array (
     'bean_id' => array (
      'width' => '15%', 
      'label' => 'LBL_ID', 
      'default' => true, 
    ), 

);

當心這種行爲將嚴重改變你的聯繫人模塊,如果你願意,你原來的行爲事後

2回還原所有更改)的更好的方式是創建一個自定義模塊,同樣的變化:1)

相關問題