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) »
  • custom fields in $params of civicrm_pre hook
Pages: [1]

Author Topic: custom fields in $params of civicrm_pre hook  (Read 863 times)

taram

  • I post occasionally
  • **
  • Posts: 35
  • Karma: 2
custom fields in $params of civicrm_pre hook
June 22, 2011, 12:20:20 pm
Hi, we are in the process of upgrading to Drupal 6 and civi 3.4. I have noticed that the custom fields in the $params of civicrm_pre hook are in the form of 'custom_field_name_table_id' (custom_4_19 where 19 is the id of the custom table). So, if I have multiple custom fields coming in from different custom tables and want to compare the data I need to parse each of the param names to get the custom field name. It seems like a tedious thing to do and was wondering what the purpose behind adding the table id to the custom field name was.
Thanks.
Tara.

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: custom fields in $params of civicrm_pre hook
August 29, 2011, 11:27:03 am
The format of custom field name is following (used when we are returning the value of specific custom field): custom_X_Y, where X is an id from civicrm_custom_field table and Y is row id from specific table where actual value of custom field is stored.

Example, to explain it better:

Let's say we're getting "custom_5_15" in our $params. In the database, we will have entry in civicrm_custom_field table with id = 5:

Code: [Select]
mysql> select id, custom_group_id, name, label, column_name from civicrm_custom_field where id = 5;
+----+-----------------+-------------------------+-------------------------+---------------------------+
| id | custom_group_id | name                    | label                   | column_name               |
+----+-----------------+-------------------------+-------------------------+---------------------------+
|  5 |               3 | Known_areas_of_interest | Known areas of interest | known_areas_of_interest_5 |
+----+-----------------+-------------------------+-------------------------+---------------------------+
1 row in set (0.00 sec)

Through custom_group_id, pointing to civicrm_custom_group, we are finding out what table the value for this custom field is stored:

Code: [Select]
mysql> select id, table_name from civicrm_custom_group where id = 3;
+----+-----------------------------------+
| id | table_name                        |
+----+-----------------------------------+
|  3 | civicrm_value_donor_information_3 |
+----+-----------------------------------+
1 row in set (0.00 sec)

Now, we are getting the value of custom field: "select * from civicrm_value_donor_information_3 where id = 15" and that's the value that we are getting in $params.

Turning that example around and coming back to purpose, we need it to be able to modify custom data records more effectively.

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) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • custom fields in $params of civicrm_pre hook

This forum was archived on 2017-11-26.