我已将电话格式修改应用于联系人的电话号码。现在,当用户保存联系人的电话号码时,它将以(xxx)xxx-xxxx的格式保存,而不是默认的xxxxxxxxxx。
但是,我想进行能够查找输入格式的记录的搜索。我修改了/custom/modules/Accounts/metadata/SearchFields.php这些更改:
'phone_office' => array(
'query_type'=>'default',
'operator' => 'subquery',
'subquery' => array(
'SELECT phone_office FROM accounts WHERE phone_office LIKE "%"',
'SELECT phone_office FROM accounts WHERE REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( phone_office, "+", "" ) , "-", "" ) , "(", "" ) , ")", "" ) , " ", "" ) LIKE "%"',
'OR' =>true
),
'db_field'=>array('phone_office'),
'vname' =>'LBL_PHONE_OFFICE',
),
但是在这些更改之后,使用此方法启动基本或高级搜索只会使浏览器处于无响应状态。显然,人们不能在“子查询”中使用数组。因为当我将它设置为仅接受其中一个select语句时,它们会贯彻执行。任何人都可以帮我解决这个问题吗?
答案 0 :(得分:1)
尝试
'phone_office' => array(
'query_type'=>'default',
'operator' => 'subquery',
'subquery' => array(
'SELECT phone_office FROM accounts WHERE phone_office LIKE ',
'SELECT phone_office FROM accounts WHERE REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( phone_office, "+", "" ) , "-", "" ) , "(", "" ) , ")", "" ) , " ", "" ) LIKE ',
'OR' =>true
),
'db_field'=>array('phone_office'),
'vname' =>'LBL_PHONE_OFFICE',
),
%是由糖添加的。 请参阅现场电话的modules \ Employees \ metadata \ SearchFields.php
答案 1 :(得分:1)
Arrgh。新手的错误。我需要在SELECT语句中用'id'替换'phone_office'。这应该是语法:
'phone_office' => array(
'query_type'=>'default',
'operator' => 'subquery',
'subquery' => array(
'SELECT id FROM accounts WHERE phone_office LIKE "%"',
'SELECT id FROM accounts WHERE REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( phone_office, "+", "" ) , "-", "" ) , "(", "" ) , ")", "" ) , " ", "" ) LIKE "%"',
'OR' =>true
),
'db_field'=>array('phone_office'),
'vname' =>'LBL_PHONE_OFFICE',
),
现在它可以正常工作。我想今天我发现只是因为它适用于MySQL并不一定意味着它会在SugarCRM中运行。谢谢你帮助我!