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 )

      { $include_email = 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 )

      { $value = "'$value%'"; $op = 'LIKE'; }

      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 )

      { $value = "'$value%'"; $op = 'LIKE'; }

      else

      { $value = "'$value'"; }

      if (strpos( $value, '@' ) === false)

      { $sub[] = " ( contact_a.sort_name $op $value OR contact_a.display_name $op $value )"; }

      else {
      if ( $include_email )

      { $sub[] = " ( civicrm_email.email $op $value )"; }

      }
      }
      if ( $include_email )

      { $this->_tables['civicrm_location'] = $this->_whereTables['civicrm_location'] = 1; $this->_tables['civicrm_email'] = $this->_whereTables['civicrm_email'] = 1; }

      }

      $this->_where[$grouping][] = ' ( ' . implode( ' AND ', $sub ) . ' ) ';
      if ( $include_email )

      { $this->_qill[$grouping][] = ts( 'Name or Email like - "%1"', array( 1 => $name ) ); }

      else

      { $this->_qill[$grouping][] = ts( 'Name like - "%1"', array( 1 => $name ) ); }


      }

        Attachments

          Activity

            People

            • Assignee:
              junia Junia Biswas
              Reporter:
              davidstrauss David Strauss
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: