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) »
  • params - I must be missing something
Pages: [1]

Author Topic: params - I must be missing something  (Read 1348 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
params - I must be missing something
August 26, 2009, 01:16:21 am
I think there must be something fundamental I just haven't twigged onto.

I want to write a hook to do some relationship 'stuff'. So I went to the api Relationship.php to see what fields I would need to pass in to create a relationship. What I see is:
Code: [Select]
/**
 * Add or update a relationship
 *
 * @param  array   $params   (reference ) input parameters
 *
 * @return array (reference) id of created or updated record
 * @static void
 * @access public
 */
function civicrm_relationship_create( &$params )

So, what I was hoping to see is what parameters I would need / could pass in in order to create a relationship but at the moment I'm no wiser. I'm sure other people have a clever way to figure it out because all I can think of doing is trawling through the code to find an example to copy. (in this case I'll look at Lobo's blog code) but there must be a more intelligent way.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: params - I must be missing something
August 26, 2009, 02:48:04 am
This might help: http://fisheye.civicrm.org/browse/CiviCRM/branches/v2.2/tests/api/v2/RelationshipCreate.test?r=19132

Kurund
Found this reply helpful? Support CiviCRM

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: params - I must be missing something
August 26, 2009, 02:56:05 am
Thanks.

I'm wondering - Lobo didn't use the API for his schools module - he just re-wrote the sql. I kind of thought the point of the API was to not have to write sql directly for these sorts of functions. Have I got it wrong?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: params - I must be missing something
August 26, 2009, 05:51:03 am

most of the times in the sql, i'm combining multiple tables to get information out in one query.

To some extent it depends on how familiar you are with sql vs php vs CiviCRM :)

The api does things more at a object level, most of my code in sfschool was dealing with 2-4 tables at the same time

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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • params - I must be missing something

This forum was archived on 2017-11-26.