I have a contribution form with profile with custom fields, I want to know where the custom fields data is stored in the DB for every new contact.
1 Answer
Quote from CiviCRM data architecture:
When you add custom data to a CiviCRM object, you first create a custom data group and then add custom data fields. At the database layer, what you are doing is creating a new table for the custom data group and adding columns for the fields.
If you crate a custom data group called My Custom Data with a field Name, Civi will create a new table in your database like this: civicrm_value_my_custom_data_1
, 1 being the group id. The table has an id column (primary key) an entity_id column (fk to the entity, ie. contact_id, contribution_id, etc), and one column per each field you have created, in this case would be name_1
.
Field Name for contact_id 50 in sql would be:
select name_1 from civicrm_value_my_custom_data_1 where entity_id=50;
Hope is clear.