CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Usability Improvements (Moderator: Dave Greenberg) »
  • Give option for search using wildcard or "LIKE" for core and custom fields
Pages: [1]

Author Topic: Give option for search using wildcard or "LIKE" for core and custom fields  (Read 1621 times)

farmrchrys

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 2
    • Spokane Moves to Amend the Constitution (under development)
  • CiviCRM version: CiviCRM 4.4.6
  • CMS version: Drupal 7.31
  • MySQL version: MySQL 5.5.37
  • PHP version: PHP 5.3.28
Give option for search using wildcard or "LIKE" for core and custom fields
June 24, 2009, 11:11:42 am
It might be nice to offer admins a choice, possibly on the fly (check box next to input field) or set in custom data field creation or preferences so that someone could enter a partial search term (similar to basic search name and email fields) rather than typing exactly the search term - without having to use wildcards. A post I read (http://forum.civicrm.org/index.php?topic=8162.0) gives a clue how to do this by hard coding, but having it in core would be good.

Chrys
« Last Edit: June 24, 2009, 01:55:06 pm by farmrchrys »

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Give option for search using wildcard or "LIKE" for core and custom fields
August 04, 2009, 08:12:29 pm
Related comment --

Text-type custom fields currently are searched using wildcards, but note/memo type fields are not. Yet I think those are just as important to search that way (think searching keywords in an organization description).

To do this, I've edited: CRM/Core/BAO/CustomQuery.php
Around line 427, replace the "Memo" case with the following:

Code: [Select]
$value = CRM_Utils_Type::escape( strtolower(trim($value)), 'String' );
                            if ( $wildcard ) {
                                $value = strtolower( addslashes( $value ) );
                                $value = "%$value%";
                                $op  = 'LIKE';
                            }

$this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause( $fieldName, $op, $value, 'String' );
$this->_qill[$grouping][]  = "$field[label] $op $qillValue";
                continue;
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Usability Improvements (Moderator: Dave Greenberg) »
  • Give option for search using wildcard or "LIKE" for core and custom fields

This forum was archived on 2017-11-26.