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) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Help with planning for working with external dB
Pages: [1]

Author Topic: Help with planning for working with external dB  (Read 845 times)

BusinessMediaCenter

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 2
  • CiviCRM version: 4.1.x
  • CMS version: Drupal 6 & 7
  • MySQL version: 5
  • PHP version: 5
Help with planning for working with external dB
March 19, 2011, 03:35:39 pm
Hello,

before I jump into the project, I would first like to ask your alls opinions on a best practice for what I want to do.

1) Civi 3.3.2 with Drupal 6.0 is installed, contacts and memberships have been imported from clients old database and all works great
2) Client has an application that will require use of a table his old mysql database, thus this table in the old db will need to be updated by civi when a contact's record and membership are updated through civi (and also created).  By having civi handle updating the old table, I will be able to avoid recoding and reconfiguring his proprietary application's functions which use the old table for things such as access control (as I am not allowed to make changes to this apps code)
3) The table to be updated will receive very basic info from civi:
-If an existing contact is updated -  First name, Last name, Membership type should be updated where the contacts external id = id in the old table
-If a contact is created - First name, last name, membership type.  I will also need an external id auto created for the civi record and then inserted into the old table's "id" row

Questions
1) Where can i find more info on this?  Perhaps using hooks?  I found this post, but  its only part of what I need:
http://forum.civicrm.org/index.php/topic,10219.msg43777.html#msg43777
2) Are there any examples that i might use to get me on the right track
3) Any suggestions for best implementation?
4) Finally- lets assume I get all of this working.  How do I then handle automatic membership statuses?  EG when someone's membership expires and civi automatically places them into the expired status, how can I get civi to update the old db when this happens?

Any bit of advice is greatly appreciated
thanks!


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: Help with planning for working with external dB
March 20, 2011, 07:27:16 am

Use hooks to catch all changes that happen in the Civi DB. I'd use the hook_civicrm_post on the Membership object. Check:

http://wiki.civicrm.org/confluence/display/CRMDOC32/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmpost

Also check:

http://en.flossmanuals.net/CiviCRM/DevelopIntro

The CiviMember <-> Drupal roles module (code in: drupal/modules/civicrm_member_roles/ in your distro) basically does the same thing (but locally). It keeps the membership in sync with a drupal role

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

BusinessMediaCenter

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 2
  • CiviCRM version: 4.1.x
  • CMS version: Drupal 6 & 7
  • MySQL version: 5
  • PHP version: 5
Re: Help with planning for working with external dB
March 21, 2011, 10:14:14 pm
thanks lobo, Ill look into these resources!

BusinessMediaCenter

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 2
  • CiviCRM version: 4.1.x
  • CMS version: Drupal 6 & 7
  • MySQL version: 5
  • PHP version: 5
Re: Help with planning for working with external dB
March 29, 2011, 09:40:20 pm
Just as a follow up, I have been able to rewrite their legacy application to query the drupal and civi tables, turns out this will be much easier and more reliable in this specific case

thanks!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Help with planning for working with external dB

This forum was archived on 2017-11-26.