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) »
  • Get all contacts with a given relationship type id
Pages: [1]

Author Topic: Get all contacts with a given relationship type id  (Read 1049 times)

dlats

  • I post occasionally
  • **
  • Posts: 77
  • Karma: 0
  • CiviCRM version: 4.0.7
  • CMS version: Drupal 7.12
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
Get all contacts with a given relationship type id
April 05, 2012, 04:15:36 am
I tried
$params = array(
            'contact_id_b' => $org_id,     
            'is_active' => 1,
            'relationship_type_id' => 12 ,
            'version'   => '3',
          );
          $relm = civicrm_api('relationship', 'get', $params);

The error message says required key is missing: contact_id

Any ideas?

dlats

  • I post occasionally
  • **
  • Posts: 77
  • Karma: 0
  • CiviCRM version: 4.0.7
  • CMS version: Drupal 7.12
  • MySQL version: 5.0.91
  • PHP version: 5.2.17
Re: Get all contacts with a given relationship type id
April 06, 2012, 12:27:37 pm
civicrm_initialize( ) ;

$sql = 'SELECT contact_id_a FROM civicrm_relationship WHERE relationship_type_id  = %1 and contact_id_b = %2;';
$params = array(1 => array(12, 'Integer'), 2=>array(110,'Integer'));
$dao =& CRM_Core_DAO::executeQuery($sql, $params);
echo ' <br>';
while ($dao_res = $dao->fetch()) {
echo 'contact_id_a = '.$dao_res.'<BR>';

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Get all contacts with a given relationship type id
April 07, 2012, 03:16:20 am
The API is asking for a param with the name 'contact_id', you feed it 'contact_id_b'. Try using 'contact_id' instead?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Get all contacts with a given relationship type id

This forum was archived on 2017-11-26.