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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Search results and returned values not equal
Pages: [1]

Author Topic: Search results and returned values not equal  (Read 782 times)

wexzone

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 0
Search results and returned values not equal
March 04, 2011, 11:19:53 am
I am running a small search on contacts.  I am getting some weird behavior.

Here is what I am using for the params:

Code: [Select]
$keyword="eco";
$type="Individual";

$params = array(
'display_name'        => $keyword,
'contact_type'       => $type,
'return.contact_id'   => 1,
'return.display_name' => 1,
);
$result = civicrm_contact_search( $params );

$countresult = civicrm_contact_search_count( $params );

if ($countresult ==0 ) {
echo"<br><br> No results";
}
else {
print_r( $countresult );
echo"<br><br>";
print_r( $result );
}

This returns 2 for $countresult (civicrm_contact_search_count);

But, the actual returns from civicrm_contact_search is 4 results, 2 of which do not contact the defined paramters.

What am I missing, here?

wexzone

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 0
Re: Search results and returned values not equal
March 04, 2011, 11:43:38 am
ok, so I see that search is depreciated, so I changed to get.  I'm still have the same issue.

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 results and returned values not equal
March 04, 2011, 12:40:11 pm
Hi,

If you are attending civicon, don't miss the API version 3 presentation by kyle, you'll discover a lot of nice new stuff.

As for your query, you don't filter anything beside the individuals, it returns all the contacts (or first 25 if you have more). return simply says what attributes to return.

The difference is weird indeed. might be a bug on the ACL or some deleted contacts? What are the two extra?
X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

wexzone

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 0
Re: Search results and returned values not equal
March 04, 2011, 01:28:00 pm
I thought I was filtering according to the $keyword:

Code: [Select]
$params = array(
            'display_name'        => $keyword,
            'contact_type'       => $type,
            'return.contact_id'   => 1,
            'return.display_name' => 1,
            );
$result = civicrm_contact_search( $params );

Is that not a correct way to search for a keyword in a name?

The 2 extra are just other Individuals.  I don't have many in the DB, just some test data.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Search results and returned values not equal

This forum was archived on 2017-11-26.