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) »
  • API Add vs Create
Pages: [1]

Author Topic: API Add vs Create  (Read 1023 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
API Add vs Create
September 21, 2010, 06:02:52 pm
Hi,

I just noticed a problem (I think) with the standards: http://wiki.civicrm.org/confluence/display/CRM/API+Conventions

The current civicrm_contact_add will perform an update or an add depending on whether you pass in a contact_id or not. This seems to me to be *better* than deprecating add in favour of using Create and Update.

Create or Add could be used but the behaviour of it 'adding' if there is no contact ID or 'updating' if there is one seems better to me than requiring people to 'pick the right function' in their code  - thoughts?
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

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: API Add vs Create
September 28, 2010, 12:47:16 am
From a standardization point of view and to make the lot more accessible for newbies I would advocate the use of create/update/delete/get which is close to CRUD. This is something I would have recognized and expected, although I am used to the add possibilities now.
Erik
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: API Add vs Create
September 28, 2010, 12:52:20 am
Which would need I'd need to maintain my own wrapper function to do what add currently does I guess? I guess it's only a few lines of code
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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: API Add vs Create
September 28, 2010, 12:54:29 am
BTW - we don't have CRUD do we? We hard CGUD
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

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: API Add vs Create
September 28, 2010, 01:40:23 am
Yep, if we were keeping to CRUD we would replace get with READ. But being a little different is nice too  ;D
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: API Add vs Create
September 28, 2010, 02:23:44 pm
Hi,

Genuinely don't care about what verb it is, at long as it says the same from one entity to the other.
Eg. can cope with civicrm_entity_add instead of create no problem, but having one civicrm_bla_add and another civicrm_bli_create makes it unpredictable and annoying to use

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

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: API Add vs Create
September 28, 2010, 11:27:57 pm
At the end of the day that is obviously the most important.
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) »
  • API Add vs Create

This forum was archived on 2017-11-26.