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) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • search by 'display_name' OR 'email' addresse
Pages: [1]

Author Topic: search by 'display_name' OR 'email' addresse  (Read 1968 times)

TrAshiBa

  • Guest
search by 'display_name' OR 'email' addresse
May 02, 2007, 06:53:36 am
Hi,

When I use the function "crm_contact_search" with civicrm 1.6, I only give one parameter which is "sort_name"
Code: [Select]
$params = array( 'sort_name' => $keyword )
and the search matches the 'keyword' with 'sort_name' and 'email' fields.  It was wonderful, it was that I am looking for.

But now, I am using civiCRM 1.7 ( 1.7.beta.9327 ), I replace the parameter ' sort_name' by 'display_name' mentioned by Swati Vaidya in the mailing list.  The fact is the parameter does a matching only with 'display_name ', I wanted to make a matching with the 'email' field too.

If I use 2 parameters, the search criteria is AND'ed as mentioned in the wiki.civicrm.org.

Does someone have a tip to suggest to have a OR'ed search criteria ?

Thanks in advance for any help :)



Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: search by 'display_name' OR 'email' addresse
May 02, 2007, 10:41:05 am

The API does not support sending in a query with OR parameters in v1.7

However you can call the code directly and get support for the above. Here are some pointers that will get you started

1. Check api/v2/Contact.php, function civicrm_contact_search. This gives u a rough idea on how to call the Query class directly

2. The first params, inputParams needs to be as follows:

$params =
array(
  array( 'display_name', 'LIKE', '%foo%', 0, 0 ),
  array( 'email'           , 'LIKE', '%foo%', 1, 0 ),
);

The 4th parmeter specifies what group the clause belongs to, and all groups are then OR'ed together

Contact us on IRC if u need more detailed help/instructions

regards

lobo


A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • search by 'display_name' OR 'email' addresse

This forum was archived on 2017-11-26.