Details
-
Type: Improvement
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 1.6
-
Fix Version/s: 1.7
-
Component/s: Core CiviCRM
-
Labels:None
Description
If you replace the corresponding function in CRM/Contact/BAO/Query.php, you'll see an immense query speed increase without any schema changes. Better yet, multiple search terms function are treated as an AND, which makes searches much more useful. I'd like at least the option to turn this code on for big CiviCRM installations.
/**
- where / qill clause for sort_name
* - @return void
- @access public
*/
function sortName( &$values ) {
list( $name, $op, $value, $grouping, $wildcard ) = $values;
$name = trim( $value );
$config =& CRM_Core_Config::singleton( );
$include_email = $config->includeEmailInSearch;
if ( strpos( $name, '@' ) === false )
$sub = array( );
// if we have a comma in the string, search for the entire string
if ( strpos( $name, ',' ) !== false ) {
$value = strtolower(addslashes($name));
if ( $wildcard )
else
{ $value = "'$value'"; } $sub[] = " ( contact_a.sort_name $op $value )";
} else {
// split the string into pieces
$pieces = explode( ' ', $name );
foreach ( $pieces as $piece ) {
$value = strtolower(addslashes(trim($piece)));
if ( $wildcard )
else
{ $value = "'$value'"; } if (strpos( $value, '@' ) === false)
else {
if ( $include_email )
}
}
if ( $include_email )
}
$this->_where[$grouping][] = ' ( ' . implode( ' AND ', $sub ) . ' ) ';
if ( $include_email )
else
{ $this->_qill[$grouping][] = ts( 'Name like - "%1"', array( 1 => $name ) ); }
}