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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Search contacts based on a list of emails
Pages: [1]

Author Topic: Search contacts based on a list of emails  (Read 1534 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Search contacts based on a list of emails
March 23, 2008, 02:12:25 am
Hi all,

I'm working on a bulk importer, where I can paste a list of emails, and the system adds the ones that aren't already in CIVI.

I've parsed the emails and I have an array of emails. I want to test if they are already known in the system.

I've seen the api to test for one email:

Code: [Select]
    civicrm_initialize(TRUE);
    $params = array ('email'  => 'dave.green@example.org');

    // Define which values we want to retrieve. $return_properties must be an assoc array
    $return_properties = array( 'first_name' => 1,
                                'last_name' => 1,
                                'email' => 1,
                                'phone' => 1,
                                'postal_code' => 1,
                                'state_province' =>1,
                                'country' => 1 );

    // Search API returns a nested array with requested return_properties
    list($myContacts,$dontCare) = crm_contact_search( $params, $return_properties);
...

But I'd like to avoid fetching them one by one and fetch all the contacts at once. Is it possible with the api/BAO ? Is there a doc on the search class ? Not very clear right now about how it works and what are the value you can put in the params.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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 contacts based on a list of emails
March 23, 2008, 12:41:55 pm

There is no api to test for an array of emails. Your best bet would be to write a direct db query to do the needful

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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Search contacts based on a list of emails
March 23, 2008, 01:47:52 pm
Hi,

Thanks.

For now, I loop through each email and get the contact. Not a big deal if the number of email imported isn't too big I suppose.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Search contacts based on a list of emails

This forum was archived on 2017-11-26.