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 (Moderator: Donald Lobo) »
  • SQL CiviCRM with Drupal: how do you select the Drupal uid for a contact id?
Pages: [1]

Author Topic: SQL CiviCRM with Drupal: how do you select the Drupal uid for a contact id?  (Read 3960 times)

netvigator

  • I’m new here
  • *
  • Posts: 26
  • Karma: 2
SQL CiviCRM with Drupal: how do you select the Drupal uid for a contact id?
May 12, 2008, 07:02:41 am
We are using CiviCRM with Drupal.

One of our users want a list of the Drupal usernames for each CiviCRM contact.  The Drupal usernames are in the users table in the name column, and the key column for the table is uid.  The application knows how to match up Drupal users with CiviCRM contacts, but I have not figured it out.  I would appreciate it if I could find out how those are matched up.

Thanks,

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: SQL CiviCRM with Drupal: how do you select the Drupal uid for a contact id?
May 12, 2008, 07:44:37 am
Hey,

Please take a look at civicrm_uf_match table - is this what you need?

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

netvigator

  • I’m new here
  • *
  • Posts: 26
  • Karma: 2
Re: SQL CiviCRM with Drupal: how do you select the Drupal uid for a contact id?
May 12, 2008, 04:32:37 pm
Excellent!!!

Thanks,

netvigator

  • I’m new here
  • *
  • Posts: 26
  • Karma: 2
Re: SQL CiviCRM with Drupal: how do you select the Drupal uid for a contact id?
May 14, 2008, 07:39:36 pm
The first answer was on the head of the nail for what I needed.

My next question is how do you match up groups in CiviCRM with "organic groups" in Drupal?

Do I need to start a separate thread?

Thanks,

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: SQL CiviCRM with Drupal: how do you select the Drupal uid for a contact id?
May 15, 2008, 02:20:45 am
You should probably take a look here: http://drupal.org/project/og_civicrm although there is not too much information there. A good source of information would be also taking a look at the code, specifically on: drupal/civicrm_og_synch.module and CRM/Bridge/OG/* files.

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

netvigator

  • I’m new here
  • *
  • Posts: 26
  • Karma: 2
Re: SQL CiviCRM with Drupal: how do you select the Drupal uid for a contact id?
May 15, 2008, 04:28:44 pm
Michal,

I looked in the source code.  I do not know php, but luckily, the SELECT statements stand out.

The most helpful was Utils.php in civicrm/CRM/Bridge/OG.

The answer is the nid from the og table is embedded in the source column of the civicrm_group table.

If you have the nid and want to find the civicrm_group table row, I think the fastest way would be to reconstruct the source text based on that nid, and search for that text in the source column.  (You could also do a like search, searching for the nid in the source text, but I think that would be less efficient at the MySQL level.)

If you know the group in CiviCRM and want to look up the og in Drupal, get the nid out of the source text (it is between colons ":"), then select for that on the Drupal side.

Unless anyone can figure out a better way, I think those are the answers.

Thanks for pointing me in the right direction.

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: SQL CiviCRM with Drupal: how do you select the Drupal uid for a contact id?
May 23, 2008, 04:46:51 am
Above looks like decent solution - thanks for sharing!

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • SQL CiviCRM with Drupal: how do you select the Drupal uid for a contact id?

This forum was archived on 2017-11-26.