CRM_Core_BAO_CustomValueTable
in package
Tags
Table of Contents
Methods
- fieldToSQLType() : string
- Given a field return the mysql data type associated with it.
- getDataTypeForField() : string
- Get the actual data type for a customField based on the entity metadata
- getDataTypeForPrimaryKey() : string
- Most entities have an Int id field, but non-database ones eg. Afform have a String "name" field as primary key
- getEntityValues() : array<string|int, mixed>
- Return an array of all custom values associated with an entity.
- getValues() : array<string|int, mixed>
- Take in an array of entityID, custom_ID and gets the value from the appropriate table.
- postProcess() : mixed
- Post process function.
- setValues() : array<string|int, mixed>
- Take in an array of entityID, custom_XXX => value and set the value in the appropriate table. Should also be able to set the value to null. Follows api parameter/return conventions
- store() : mixed
- create() : mixed
- deleteFile() : mixed
- Delete orphaned files from disk when updating custom file fields
Methods
fieldToSQLType()
Given a field return the mysql data type associated with it.
public
static fieldToSQLType(string $type[, int|null $maxLength = null ][, bool $isSerialized = false ][, string|null $fkEntity = null ]) : string
Parameters
- $type : string
- $maxLength : int|null = null
- $isSerialized : bool = false
-
(serialized fields must always have a textual mysql field)
- $fkEntity : string|null = null
-
The entity that the CustomField (CustomGroup) extends. eg. Activity
Return values
string —the mysql data store placeholder
getDataTypeForField()
Get the actual data type for a customField based on the entity metadata
public
static getDataTypeForField(int $customFieldID, string $type) : string
Parameters
- $customFieldID : int
- $type : string
Tags
Return values
stringgetDataTypeForPrimaryKey()
Most entities have an Int id field, but non-database ones eg. Afform have a String "name" field as primary key
public
static getDataTypeForPrimaryKey(string $entityName) : string
Parameters
- $entityName : string
Tags
Return values
stringgetEntityValues()
Return an array of all custom values associated with an entity.
public
static getEntityValues(int $entityID[, string $entityType = null ][, array<string|int, mixed> $fieldIDs = null ][, bool $formatMultiRecordField = false ][, array<string|int, mixed> $DTparams = null ]) : array<string|int, mixed>
Parameters
- $entityID : int
-
Identification number of the entity.
- $entityType : string = null
-
Type of entity that the entityID corresponds to, specified. as a string with format "'<EntityName>'". Comma separated list may be used to specify OR matches. Allowable values are enumerated types in civicrm_custom_group.extends field. Optional. Default value assumes entityID references a contact entity.
- $fieldIDs : array<string|int, mixed> = null
-
Optional list of fieldIDs that we want to retrieve. If this. is set the entityType is ignored
- $formatMultiRecordField : bool = false
- $DTparams : array<string|int, mixed> = null
-
- CRM-17810 dataTable params for the multiValued custom fields.
Tags
Return values
array<string|int, mixed> —Array of custom values for the entity with key=>value pairs specified as civicrm_custom_field.id => custom value. Empty array if no custom values found.
getValues()
Take in an array of entityID, custom_ID and gets the value from the appropriate table.
public
static getValues(array<string|int, mixed> $params) : array<string|int, mixed>
To get the values of custom fields with IDs 13 and 43 for contact ID 1327, use: $params = array( 'entityID' => 1327, 'custom_13' => 1, 'custom_43' => 1 );
Entity Type will be inferred by the custom fields you request Specify $params['entityType'] if you do not supply any custom fields to return and entity type is other than Contact
Parameters
- $params : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>postProcess()
Post process function.
public
static postProcess(array<string|int, mixed> &$params, string $entityTable, int $entityID, string|null $customFieldExtends[, string|null $parentOperation = null ]) : mixed
Parameters
- $params : array<string|int, mixed>
- $entityTable : string
- $entityID : int
- $customFieldExtends : string|null
-
Can be null for multivalued fields
- $parentOperation : string|null = null
setValues()
Take in an array of entityID, custom_XXX => value and set the value in the appropriate table. Should also be able to set the value to null. Follows api parameter/return conventions
public
static setValues(array<string|int, mixed> &$params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>store()
public
static store(array<string|int, mixed> $params, mixed $entityTable, int $entityID[, string $parentOperation = null ]) : mixed
Parameters
- $params : array<string|int, mixed>
- $entityTable : mixed
- $entityID : int
- $parentOperation : string = null
-
Operation being taken on the parent entity. If we know the parent entity is doing an insert we can skip the ON DUPLICATE UPDATE - which improves performance and reduces deadlocks.
- edit
- create
create()
private
static create(array<string|int, mixed> $customParams[, string $parentOperation = null ]) : mixed
Parameters
- $customParams : array<string|int, mixed>
- $parentOperation : string = null
-
Operation being taken on the parent entity. If we know the parent entity is doing an insert we can skip the ON DUPLICATE UPDATE - which improves performance and reduces deadlocks.
- edit
- create
Tags
deleteFile()
Delete orphaned files from disk when updating custom file fields
private
static deleteFile(array<string|int, mixed> $field) : mixed
Parameters
- $field : array<string|int, mixed>