Documentation

CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact
in package
implements HookInterface

Placeholder class retained for legacy compatibility.

Tags
copyright

CiviCRM LLC https://civicrm.org/licensing

Table of Contents

Interfaces

HookInterface
Interface HookInterface

Constants

BULK_INSERT_COUNT  = 200
BULK_INSERT_HIGH_COUNT  = 200
CREATE_STRIP_FUNCTION_43  = "\n CREATE FUNCTION civicrm_strip_non_numeric(input VARCHAR(255))\n RETURNS VARCHAR(255)\n DETERMINISTIC\n NO SQL\n BEGIN\n DECLARE output VARCHAR(255) DEFAULT '';\n DECLARE iterator INT DEFAULT 1;\n WHILE iterator < (LENGTH(input) + 1) DO\n IF SUBSTRING(input, iterator, 1) IN ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') THEN\n SET output = CONCAT(output, SUBSTRING(input, iterator, 1));\n END IF;\n SET iterator = iterator + 1;\n END WHILE;\n RETURN output;\n END"
DB_DAO_NOTNULL  = 128
DROP_STRIP_FUNCTION_43  = "DROP FUNCTION IF EXISTS civicrm_strip_non_numeric"
SQL function used to format the phone_numeric field via trigger.
IS_NULL  = 2
NOT_NULL  = 1
QUERY_FORMAT_NO_QUOTES  = 2
QUERY_FORMAT_WILDCARD  = 1
SERIALIZE_COMMA  = 5
Comma separated string, no quotes, no spaces
SERIALIZE_JSON  = 3
Recommended serialization format
SERIALIZE_NONE  = 0
No serialization.
SERIALIZE_PHP  = 4
SERIALIZE_SEPARATOR_BOOKEND  = 1
Serialized string separated by and bookended with VALUE_SEPARATOR
SERIALIZE_SEPARATOR_TRIMMED  = 2
VALUE_SEPARATOR  = "\x01"

Properties

$_commPrefs  : array<string|int, mixed>
The types of communication preferences.
$_dbColumnValueCache  : mixed
$_exportableFields  : array<string|int, mixed>
Static field for all the contact information that we can potentially export.
$_greetingTypes  : array<string|int, mixed>
Types of greetings.
$_icon  : string
Icon associated with this entity.
$_importableFields  : array<string|int, mixed>
Static field for all the contact information that we can potentially import.
$_labelField  : string
Field to show when displaying a record.
$_nullArray  : array<string|int, mixed>
$_nullObject  : null
$_primaryKey  : array<string|int, string>
Primary key field(s).
$_testEntitiesToSkip  : array<string|int, mixed>
Define entities that shouldn't be created or deleted when creating/ deleting test objects - this prevents world regions, countries etc from being added / deleted
$addressee_custom  : string|null
$addressee_display  : string|null
$addressee_id  : int|string|null
$api_key  : string|null
$birth_date  : string|null
$communication_style_id  : int|string|null
$contact_sub_type  : string|null
$contact_type  : string|null
$created_date  : string
$deceased_date  : string|null
$display_name  : string|null
$do_not_email  : bool|string
$do_not_mail  : bool|string
$do_not_phone  : bool|string
$do_not_sms  : bool|string
$do_not_trade  : bool|string
$email_greeting_custom  : string|null
$email_greeting_display  : string|null
$email_greeting_id  : int|string|null
$employer_id  : int|string|null
$external_identifier  : string|null
$first_name  : string|null
$formal_title  : string|null
$gender_id  : int|string|null
$hash  : string|null
$household_name  : string|null
$id  : int|string|null
$image_URL  : string|null
$is_deceased  : bool|string
$is_deleted  : bool|string
$is_opt_out  : bool|string
$job_title  : string|null
$last_name  : string|null
$legal_identifier  : string|null
$legal_name  : string|null
$middle_name  : string|null
$modified_date  : string
$nick_name  : string|null
$organization_name  : string|null
$postal_greeting_custom  : string|null
$postal_greeting_display  : string|null
$postal_greeting_id  : int|string|null
$preferred_communication_method  : string|null
$preferred_language  : string|null
$preferred_mail_format  : string|null
$prefix_id  : int|string|null
$primary_contact_id  : int|string|null
$sic_code  : string|null
$sort_name  : string|null
$source  : string|null
$suffix_id  : int|string|null
$user_unique_id  : string|null
$_options  : array<string|int, mixed>
https://issues.civicrm.org/jira/browse/CRM-17748 internal variable for DAO to hold per-query settings
$resultCopies  : int
How many times has this instance been cloned.

Methods

__clone()  : mixed
__construct()  : static
Class constructor.
__destruct()  : mixed
Class destructor.
acceptedSQLOperators()  : array<string|int, string>
add()  : CRM_Contact_DAO_Contact|CRM_Core_Error|null
Takes an associative array and creates a contact object.
addBillingNameFieldsIfOtherwiseNotSet()  : mixed
Add billing fields to the params if appropriate.
addSelectWhereClause()  : array<string|int, mixed>
Generates acl clauses suitable for adding to WHERE or ON when doing an api.get for this entity
alterContactSubType()  : mixed
Pseudoconstant condition_provider for contact_sub_type field.
appendPseudoConstantsToFields()  : mixed
Update the fields array to also hold keys for pseudoconstant fields that relate to contained fields.
buildOptions()  : array<string|int, mixed>|bool
Legacy option getter
buildOptionsContext()  : array<string|int, mixed>
Provides documentation and validation for the buildOptions $context param
cascadeUpdate()  : CRM_Core_DAO|null
Cascade update through related entities.
checkConstraintExists()  : bool
Checks if a constraint exists for a specified table.
checkDomainContact()  : bool
Check if contact is being used in civicrm_domain based on $contactId.
checkFieldHasAlwaysValue()  : mixed
Check whether a specific column in a specific table has always the same value.
checkFieldIsAlwaysNull()  : mixed
Check whether a specific column in a specific table is always NULL.
checkFKConstraintInFormat()  : mixed
Checks if the FK constraint name is in the format 'FK_tableName_columnName' for a specified column of a table.
checkTableExists()  : bool
Check if there is a given table in the database.
checkTableHasData()  : bool
Check if a given table has data.
checkTriggerViewPermission()  : bool
checkUserMenuPermissions()  : bool
Check if user has permissions to access items in action menu.
commonRetrieveAll()  : object
Fetch object based on array of properties.
composeQuery()  : string
Compose the query by merging the parameters into it.
contextMenu()  : array<string|int, mixed>
Build context menu items.
copyCustomFields()  : mixed
Method that copies custom fields values from an old entity to a new one.
copyGeneric()  : CRM_Core_DAO|bool
Make a shallow copy of an object and all the fields in the object.
copyValues()  : bool
Given an associative array of name/value pairs, extract all the values that belong to this object and initialize the object with said values
create()  : CRM_Contact_BAO_Contact|CRM_Core_Error|null
Create contact.
createProfileContact()  : int
Add/edit/register contacts through profile.
createReferenceColumns()  : array<string|int, CRM_Core_Reference_Interface>
Given a list of fields, create a list of references.
createSQLFilter()  : null|string|array<string|int, mixed>
Get SQL where clause for SQL filter syntax input parameters.
createTestObject()  : object|array<string|int, mixed>|null
Creates a test object, including any required objects it needs via recursion createOnly: only create in database, do not store or return the objects (useful for perf testing) ONLY USE FOR TESTING
createTriggers()  : mixed
debugPrint()  : mixed
delete()  : int|false
Deletes items from table which match current objects variables.
deleteContact()  : bool
Delete a contact and all its associated records.
deleteContactImage()  : bool
Delete the image of a contact.
deleteEntityContact()  : mixed
Unused function.
deleteRecord()  : static
Delete a record from supplied params.
deleteRecords()  : array<string|int, static>
Bulk delete multiple records.
deleteTestObjects()  : mixed
Deletes the this object plus any dependent objects that are associated with it.
disableFullGroupByMode()  : mixed
Disables usage of the ONLY_FULL_GROUP_BY Mode if necessary
displayName()  : null|string
Get the display name of a contact.
dropAllTables()  : mixed
Drop all CiviCRM tables.
dropTriggers()  : mixed
Wrapper function to drop triggers.
ensureGreetingParamsAreSet()  : mixed
Ensure greeting parameters are set.
escapeString()  : string
escapeStrings()  : string
Escape a list of strings for use with "WHERE X IN (...)" queries.
escapeWildCardString()  : string
executeQuery()  : CRM_Core_DAO|object
Execute a query.
executeUnbufferedQuery()  : CRM_Core_DAO
Execute an unbuffered query.
export()  : array<string|int, mixed>
Returns the list of fields that can be exported
exportableFields()  : array<string|int, mixed>
Combine all the exportable fields from the lower levels object.
fetchAll()  : array<string|int, mixed>
Returns all results as array-encoded records.
fetchGenerator()  : mixed
Return the results as PHP generator.
fetchMap()  : array<string|int, mixed>
Get all the result records as mapping between columns.
fetchValue()  : mixed|null
Returns a singular value.
fieldKeys()  : array<string|int, mixed>
Return a mapping from field-name to the corresponding key (as used in fields()).
fields()  : array<string|int, mixed>
Returns all the column names of this table.
fillValues()  : array<string|int, mixed>
Given an incomplete record, attempt to fill missing field values from the database
findById()  : static
Find a DAO object for the given ID and return it.
findDuplicates()  : array<string|int, mixed>
findReferences()  : array<string|int, CRM_Core_DAO>
Find all records which refer to this entity.
formatFieldValues()  : void
Format field values according to fields() metadata.
formatProfileContactParams()  : array<string|int, mixed>
Format profile contact parameters.
freeResult()  : mixed
getAttribute()  : array<string|int, mixed>
Get the size and maxLength attributes for this text field.
getConnection()  : DB_common
getContactDetails()  : array<string|int, mixed>
Get the display name, primary email and location type of a contact.
getContactIDsFromComponent()  : array<string|int, mixed>
Given the component id, compute the contact id since its used for things like send email
getContactSubType()  : string
Get contact sub type for a contact.
getContactType()  : string
Get contact type for a contact.
getContactTypes()  : array<string|int, mixed>
Get pair of contact-type and sub-type for a contact.
getCountComponent()  : int|false
Provides counts for the contact summary tabs.
getDatabaseName()  : string
Get the name of the CiviCRM database.
getDbVal()  : array<string|int, mixed>|bool|int|string|null
Fetch a single field value from the database.
getDefaultFallbackValues()  : mixed
Callback for `default_fallback` field values
getDisplayAndImage()  : array<string|int, mixed>|null
Get the display name and image of a contact.
getDuplicateContacts()  : array<string|int, mixed>
Get any existing duplicate contacts based on the input parameters.
getDynamicReferencesToTable()  : array<string|int, mixed>
Get all dynamic references to the given table.
getEntityDescription()  : string|null
Returns user-friendly description of this entity.
getEntityIcon()  : string|null
Get icon for a particular contact.
getEntityPaths()  : array<string|int, mixed>
Returns system paths related to this entity (as defined in the xml schema)
getEntityRefCreateLinks()  : array<string|int, mixed>|false
getEntityRefFilters()  : array<string|int, mixed>
getEntityTitle()  : string
Returns localized title of this entity.
getExportableFieldsWithPseudoConstants()  : array<string|int, mixed>
Get exportable fields with pseudoconstants rendered as an extra field.
getExtensionName()  : string|null
Get name of extension in which this DAO is defined.
getFieldSpec()  : bool|array<string|int, mixed>
getFieldValue()  : string|int|null
Given a DAO name, a column name and a column value, find the record and GET the value of another column in that record
getFirstDuplicateContact()  : int|null
Get the first duplicate contacts based on the input parameters.
getGlobalSetting()  : mixed
Lookup the value of a MySQL global configuration variable.
getHierContactDetails()  : array<string|int, mixed>
Get the all contact details (Hierarchical).
getLabelField()  : string|null
getLocaleTableName()  : string
Get localized name of this table, if applicable.
getLocBlockIds()  : array<string|int, mixed>
Retrieve loc block ids w/ given condition.
getLog()  : bool
Returns if this table needs to be logged
getMasterDisplayName()  : string|null
Retrieve display name of contact that address is shared.
getOptionLabels()  : mixed
Populate option labels for this object's fields.
getPrimaryEmail()  : string
Get primary email of the contact.
getPrimaryLocationType()  : int|null
Return the primary location type of a contact.
getReferenceColumns()  : array<string|int, CRM_Core_Reference_Basic>
Returns list of FK relationships.
getReferenceCounts()  : array<string|int, array{name: string, type: string, count: int, table: string|null, key: string|null}>
getReferencesToContactTable()  : mixed
Get all references to contact table.
getReferencesToTable()  : array<string|int, CRM_Core_Reference_Interface>
List all tables which have either: - hard foreign keys to this table, or - a dynamic foreign key that includes this table as a possible target.
getSelectWhereClause()  : array<string|int, mixed>
This returns the final permissioned query string for this entity
getSortString()  : mixed
Unused function.
getSupportedFields()  : array<string|int, mixed>
Returns all usable fields, indexed by name.
getTableName()  : string
Returns the name of this table
getTableNames()  : array<string|int, mixed>
Gets the names of all enabled schema tables.
getThumbSize()  : array<string|int, mixed>
Return proportional height and width of the image.
getTimestamps()  : array<string|int, mixed>
Get the creation/modification times for a contact.
getValues()  : CRM_Contact_BAO_Contact|null
Fetch the object and store the values in the values array.
hasName()  : bool
Check if a contact has a name.
import()  : array<string|int, mixed>
Returns the list of fields that can be imported
importableFields()  : array<string|int, mixed>
Combine all the importable fields from the lower levels object.
indices()  : array<string|int, mixed>
init()  : mixed
Initialize the DAO object.
initialize()  : mixed
Initialization for all DAO objects. Since we access DB_DO programatically we need to set the links manually.
isComponentEnabled()  : bool
Check if component is enabled for this DAO class
isDBMyISAM()  : bool
isFieldHasLocationType()  : bool
Check if a field is associated with an entity that has a location type.
isValidOption()  : bool
Wrapper to validate internal DAO options before passing to DB_mysql/DB_Common level
keys()  : array<string|int, string>
Returns primary keys (usually ['id'])
log()  : mixed
makeAttribute()  : array<string|int, mixed>|null
Create an attribute for this specific field. We only do this for strings and text
makeHierReturnProperties()  : array<string|int, mixed>
Given a set of flat profile style field names, create a hierarchy.
matchContactOnEmail()  : object|null
Find the get contact details.
matchContactOnOpenId()  : object|null
Find the contact details associated with an OpenID.
objectExists()  : bool
Check if there is a record with the same name in the db.
on_hook_civicrm_post()  : mixed
Event fired after modifying any entity.
processGreetings()  : void
Process greetings and cache.
processImage()  : mixed
Extract contact id from url for deleting contact image.
processImageParams()  : bool
Validate type of contact image.
query()  : object
Execute a query by the current DAO, localizing it along the way (if needed).
reenableFullGroupByMode()  : mixed
Re-enables ONLY_FULL_GROUP_BY sql_mode as necessary.
requireSafeDBName()  : bool
ensure database name is 'safe', i.e. only contains word characters (includes underscores) and dashes, and contains at least one [a-z] case insensitive.
reset()  : mixed
Reset the DAO object.
retrieve()  : CRM_Contact_BAO_Contact
Fetch object based on array of properties.
save()  : CRM_Core_DAO
Save DAO object.
schemaRequiresRebuilding()  : mixed
Checks if CONSTRAINT keyword exists for a specified table.
self_civi_api4_authorizeRecord()  : void
Check contact access.
sequenceKey()  : array<string|int, mixed>
Tells DB_DataObject which keys use autoincrement.
serializeField()  : string|null
Transform an array to a serialized string for database storage.
setApiFilter()  : mixed
setCreateDefaults()  : mixed
Set defaults when creating new entity.
setFieldValue()  : bool
Given a DAO name, a column name and a column value, find the record and SET the value of another column in that record
setOptions()  : mixed
https://issues.civicrm.org/jira/browse/CRM-17748 Sets the internal options to be used on a query
shortenSQLName()  : string
SQL has a limit of 64 characters on various names: table name, trigger name, column name ... For custom groups and fields we generated names from user entered input which can be longer than this length, this function helps with creating strings that meet various criteria.
singleValueQuery()  : string|null
Execute a query and get the single result.
storeValues()  : mixed
Store all the values from this object in an associative array this is a destructive store, calling function is responsible for keeping sanity of id's.
table()  : array<string|int, mixed>
Get/set an associative array of table columns
tableHasBeenAdded()  : bool
Checks if this DAO's table ought to exist.
triggerInfo()  : mixed
Get a list of triggers for the contact table.
triggerRebuild()  : mixed
Build a list of triggers via hook and add them to (err, reconcile them with) the database.
unSerializeField()  : array<string|int, mixed>|null
Transform a serialized string from the database into an array.
unsetProtectedFields()  : mixed
Format the output of the create contact function
updateContactCache()  : mixed
Action to update any caches relating to a recently update contact.
updateGreetingsOnTokenFieldChange()  : mixed
Update contact greetings if an update has resulted in a custom field change.
writeRecord()  : static
Create or update a record from supplied params.
writeRecords()  : array<string|int, static>
Bulk save multiple records
_setDBOptions()  : mixed
https://issues.civicrm.org/jira/browse/CRM-17748 wrapper to pass internal DAO options down to DB_mysql/DB_Common level
assignTestFK()  : mixed
assignTestValue()  : mixed
Generate and assign an arbitrary value to a field of a test object.
contactTrash()  : bool
Soft delete a contact.
copyLocalizable()  : mixed
Method that copies localizable fields from an old entity to a new one.
formatFieldValue()  : mixed
Format a value according to field metadata.
getDynamicFkAclClauses()  : array<string|int, mixed>
Get an array of ACL clauses for a dynamic FK (entity_id/entity_table combo)
getFirstPrimaryKey()  : string
getLocationEntityForKey()  : string
Get the relevant location entity for the array key.
getTableAddVersion()  : string
resolveStateProvinceID()  : int|null
Resolve a state province string (UT or Utah) to an ID.
clearDbColumnValueCache()  : mixed
Remove item from static cache during update/delete operations
getEntityDefinition()  : array<string|int, mixed>
getEntityInfo()  : array<string|int, mixed>
getFieldLength()  : string|null
getSchemaFields()  : array<string|int, mixed>
getTemplateForGreeting()  : string
Get the template string for the given greeting.
loadSchemaFields()  : array<string|int, mixed>
makeNameFromLabel()  : void
When creating a record without a supplied name, create a unique, clean name derived from the label.
setDefaultsFromCallback()  : void
Set default values for fields based on callback functions

Constants

BULK_INSERT_COUNT

public mixed BULK_INSERT_COUNT = 200

BULK_INSERT_HIGH_COUNT

public mixed BULK_INSERT_HIGH_COUNT = 200

CREATE_STRIP_FUNCTION_43

public mixed CREATE_STRIP_FUNCTION_43 = "\n CREATE FUNCTION civicrm_strip_non_numeric(input VARCHAR(255))\n RETURNS VARCHAR(255)\n DETERMINISTIC\n NO SQL\n BEGIN\n DECLARE output VARCHAR(255) DEFAULT '';\n DECLARE iterator INT DEFAULT 1;\n WHILE iterator < (LENGTH(input) + 1) DO\n IF SUBSTRING(input, iterator, 1) IN ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') THEN\n SET output = CONCAT(output, SUBSTRING(input, iterator, 1));\n END IF;\n SET iterator = iterator + 1;\n END WHILE;\n RETURN output;\n END"

DB_DAO_NOTNULL

public mixed DB_DAO_NOTNULL = 128

DROP_STRIP_FUNCTION_43

SQL function used to format the phone_numeric field via trigger.

public mixed DROP_STRIP_FUNCTION_43 = "DROP FUNCTION IF EXISTS civicrm_strip_non_numeric"
Tags
see
self::triggerInfo()

Note that this is also used by the 4.3 upgrade script.

see
CRM_Upgrade_Incremental_php_FourThree

IS_NULL

public mixed IS_NULL = 2

NOT_NULL

public mixed NOT_NULL = 1

QUERY_FORMAT_NO_QUOTES

public mixed QUERY_FORMAT_NO_QUOTES = 2

QUERY_FORMAT_WILDCARD

public mixed QUERY_FORMAT_WILDCARD = 1

SERIALIZE_COMMA

Comma separated string, no quotes, no spaces

public mixed SERIALIZE_COMMA = 5

SERIALIZE_JSON

Recommended serialization format

public mixed SERIALIZE_JSON = 3

SERIALIZE_NONE

No serialization.

public mixed SERIALIZE_NONE = 0

SERIALIZE_PHP

format using php serialize()

public mixed SERIALIZE_PHP = 4

SERIALIZE_SEPARATOR_BOOKEND

Serialized string separated by and bookended with VALUE_SEPARATOR

public mixed SERIALIZE_SEPARATOR_BOOKEND = 1

SERIALIZE_SEPARATOR_TRIMMED

format separated by VALUE_SEPARATOR

public mixed SERIALIZE_SEPARATOR_TRIMMED = 2

VALUE_SEPARATOR

public mixed VALUE_SEPARATOR = "\x01"

Properties

$_commPrefs

The types of communication preferences.

public static array<string|int, mixed> $_commPrefs = ['do_not_phone', 'do_not_email', 'do_not_mail', 'do_not_sms', 'do_not_trade']

$_dbColumnValueCache

public static mixed $_dbColumnValueCache = \NULL

$_exportableFields

Static field for all the contact information that we can potentially export.

public static array<string|int, mixed> $_exportableFields = \NULL

$_greetingTypes

Types of greetings.

public static array<string|int, mixed> $_greetingTypes = ['addressee', 'email_greeting', 'postal_greeting']

$_icon

Icon associated with this entity.

public static string $_icon = \NULL

$_importableFields

Static field for all the contact information that we can potentially import.

public static array<string|int, mixed> $_importableFields = []

$_labelField

Field to show when displaying a record.

public static string $_labelField = \NULL

$_nullArray

public static array<string|int, mixed> $_nullArray = []

$_nullObject

public static null $_nullObject = \NULL

$_primaryKey

Primary key field(s).

public static array<string|int, string> $_primaryKey = ['id']

$_testEntitiesToSkip

Define entities that shouldn't be created or deleted when creating/ deleting test objects - this prevents world regions, countries etc from being added / deleted

public static array<string|int, mixed> $_testEntitiesToSkip = []

$addressee_custom

public string|null $addressee_custom

$addressee_display

public string|null $addressee_display

$addressee_id

public int|string|null $addressee_id

$birth_date

public string|null $birth_date

$communication_style_id

public int|string|null $communication_style_id

$contact_sub_type

public string|null $contact_sub_type

$contact_type

public string|null $contact_type

$created_date

public string $created_date

$deceased_date

public string|null $deceased_date

$display_name

public string|null $display_name

$do_not_email

public bool|string $do_not_email

$do_not_mail

public bool|string $do_not_mail

$do_not_phone

public bool|string $do_not_phone

$do_not_sms

public bool|string $do_not_sms

$do_not_trade

public bool|string $do_not_trade

$email_greeting_custom

public string|null $email_greeting_custom

$email_greeting_display

public string|null $email_greeting_display

$email_greeting_id

public int|string|null $email_greeting_id

$employer_id

public int|string|null $employer_id

$external_identifier

public string|null $external_identifier

$first_name

public string|null $first_name

$formal_title

public string|null $formal_title

$gender_id

public int|string|null $gender_id

$household_name

public string|null $household_name

$image_URL

public string|null $image_URL

$is_deceased

public bool|string $is_deceased

$is_deleted

public bool|string $is_deleted

$is_opt_out

public bool|string $is_opt_out

$job_title

public string|null $job_title

$last_name

public string|null $last_name
public string|null $legal_identifier
public string|null $legal_name

$middle_name

public string|null $middle_name

$modified_date

public string $modified_date

$nick_name

public string|null $nick_name

$organization_name

public string|null $organization_name

$postal_greeting_custom

public string|null $postal_greeting_custom

$postal_greeting_display

public string|null $postal_greeting_display

$postal_greeting_id

public int|string|null $postal_greeting_id

$preferred_communication_method

public string|null $preferred_communication_method

$preferred_language

public string|null $preferred_language

$preferred_mail_format

public string|null $preferred_mail_format

$prefix_id

public int|string|null $prefix_id

$primary_contact_id

public int|string|null $primary_contact_id

$sic_code

public string|null $sic_code

$sort_name

public string|null $sort_name

$suffix_id

public int|string|null $suffix_id

$user_unique_id

public string|null $user_unique_id

$_options

https://issues.civicrm.org/jira/browse/CRM-17748 internal variable for DAO to hold per-query settings

protected array<string|int, mixed> $_options = []

$resultCopies

How many times has this instance been cloned.

protected int $resultCopies = 0

Methods

__clone()

public __clone() : mixed

__construct()

Class constructor.

public __construct() : static
Return values
static

__destruct()

Class destructor.

public __destruct() : mixed

acceptedSQLOperators()

public static acceptedSQLOperators() : array<string|int, string>
Tags
see
http://issues.civicrm.org/jira/browse/CRM-9150

support for other syntaxes is discussed in ticket but being put off for now

Return values
array<string|int, string>

add()

Takes an associative array and creates a contact object.

public static add(array<string|int, mixed> &$params) : CRM_Contact_DAO_Contact|CRM_Core_Error|null

The function extracts all the params it needs to initialize the create a contact object. the params array could contain additional unused name/value pairs

Parameters
$params : array<string|int, mixed>

(reference) an assoc array of name/value pairs.

Tags
throws
CRM_Core_Exception
Return values
CRM_Contact_DAO_Contact|CRM_Core_Error|null

Created or updated contact object or error object. (error objects are being phased out in favour of exceptions)

addBillingNameFieldsIfOtherwiseNotSet()

Add billing fields to the params if appropriate.

public static addBillingNameFieldsIfOtherwiseNotSet(array<string|int, mixed> &$params) : mixed

If we have ANY name fields then we want to ignore all the billing name fields. However, if we don't then we should set the name fields to the billing fields AND add the preserveDBName parameter (which will tell the BAO only to set those fields if none already exist.

We specifically don't want to set first name from billing and last name form an on-page field. Mixing & matching is best done by hipsters.

Parameters
$params : array<string|int, mixed>
Tags
fixme

How does this relate to almost the same thing being done in CRM_Core_Form::formatParamsForPaymentProcessor()

addSelectWhereClause()

Generates acl clauses suitable for adding to WHERE or ON when doing an api.get for this entity

public addSelectWhereClause([string|null $entityName = NULL ][, int|null $userId = NULL ][, array<string|int, mixed> $conditions = [] ]) : array<string|int, mixed>
Parameters
$entityName : string|null = NULL
$userId : int|null = NULL
$conditions : array<string|int, mixed> = []
Tags
inheritDoc
Return values
array<string|int, mixed>

alterContactSubType()

Pseudoconstant condition_provider for contact_sub_type field.

public static alterContactSubType(string $fieldName, CRM_Utils_SQL_Select $conditions, mixed $params) : mixed
Parameters
$fieldName : string
$conditions : CRM_Utils_SQL_Select
$params : mixed
Tags
see
EntityMetadataBase::getConditionFromProvider

appendPseudoConstantsToFields()

Update the fields array to also hold keys for pseudoconstant fields that relate to contained fields.

public static appendPseudoConstantsToFields(array<string|int, mixed> &$fields) : mixed

This is relevant where we want to offer both the ID field and the label field as an option, e.g. search builder.

It is currently limited for optionGroupName & id+ name+ FK combos for purposes keeping the scope of the change small, but is appropriate for other sorts of pseudoconstants.

Parameters
$fields : array<string|int, mixed>

buildOptions()

Legacy option getter

public static buildOptions(mixed $fieldName[, mixed $context = NULL ][, mixed $props = [] ]) : array<string|int, mixed>|bool
Parameters
$fieldName : mixed
$context : mixed = NULL
$props : mixed = []
Tags
inheritDoc
Return values
array<string|int, mixed>|bool

buildOptionsContext()

Provides documentation and validation for the buildOptions $context param

public static buildOptionsContext([string $context = NULL ]) : array<string|int, mixed>
Parameters
$context : string = NULL
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

cascadeUpdate()

Cascade update through related entities.

public static cascadeUpdate(string $daoName, mixed $fromId, mixed $toId[, array<string|int, mixed> $newData = [] ]) : CRM_Core_DAO|null
Parameters
$daoName : string
$fromId : mixed
$toId : mixed
$newData : array<string|int, mixed> = []
Return values
CRM_Core_DAO|null

checkConstraintExists()

Checks if a constraint exists for a specified table.

public static checkConstraintExists(string $tableName, string $constraint) : bool
Parameters
$tableName : string
$constraint : string
Tags
throws
CRM_Core_Exception
Return values
bool

true if constraint exists, false otherwise

checkDomainContact()

Check if contact is being used in civicrm_domain based on $contactId.

public static checkDomainContact(int $contactId) : bool
Parameters
$contactId : int

Contact id.

Return values
bool

true if present else false.

checkFieldHasAlwaysValue()

Check whether a specific column in a specific table has always the same value.

public static checkFieldHasAlwaysValue(mixed $tableName, mixed $columnName, mixed $columnValue) : mixed

in 5.72 will be removed in 5.85

Parameters
$tableName : mixed
$columnName : mixed
$columnValue : mixed

checkFieldIsAlwaysNull()

Check whether a specific column in a specific table is always NULL.

public static checkFieldIsAlwaysNull(mixed $tableName, mixed $columnName) : mixed

in 5.72 will be removed in 5.85

Parameters
$tableName : mixed
$columnName : mixed

checkFKConstraintInFormat()

Checks if the FK constraint name is in the format 'FK_tableName_columnName' for a specified column of a table.

public static checkFKConstraintInFormat(mixed $tableName, mixed $columnName) : mixed

in 5.72 will be removed in 5.85

Parameters
$tableName : mixed
$columnName : mixed

checkTableExists()

Check if there is a given table in the database.

public static checkTableExists(string $tableName) : bool
Parameters
$tableName : string
Return values
bool

true if exists, else false

checkTableHasData()

Check if a given table has data.

public static checkTableHasData(string $tableName) : bool
Parameters
$tableName : string
Return values
bool

TRUE if $tableName has at least one record.

checkTriggerViewPermission()

public static checkTriggerViewPermission([bool $view = TRUE ][, bool $trigger = TRUE ]) : bool
Parameters
$view : bool = TRUE
$trigger : bool = TRUE
Return values
bool

checkUserMenuPermissions()

Check if user has permissions to access items in action menu.

public static checkUserMenuPermissions(array<string|int, mixed> $aclPermissionedTasks, string $corePermission, array<string|int, mixed> $menuOptions) : bool
Parameters
$aclPermissionedTasks : array<string|int, mixed>

Array containing ACL related tasks.

$corePermission : string

The permission of the user (edit or view or null).

$menuOptions : array<string|int, mixed>

Array containing params of the menu (title, href, etc).

Return values
bool

TRUE if user has all permissions, FALSE if otherwise.

commonRetrieveAll()

Fetch object based on array of properties.

public static commonRetrieveAll(string $daoName, string $fieldIdName, int $fieldId, mixed &$details[, array<string|int, mixed> $returnProperities = NULL ]) : object
Parameters
$daoName : string

Name of the dao object.

$fieldIdName : string
$fieldId : int
$details : mixed
$returnProperities : array<string|int, mixed> = NULL

An assoc array of fields that need to be returned, eg array( 'first_name', 'last_name').

Return values
object

an object of type referenced by daoName

composeQuery()

Compose the query by merging the parameters into it.

public static composeQuery(string $query[, array<string|int, mixed> $params = [] ][, bool $abort = TRUE ]) : string
Parameters
$query : string
$params : array<string|int, mixed> = []
$abort : bool = TRUE
Tags
throws
CRM_Core_Exception
Return values
string

contextMenu()

Build context menu items.

public static contextMenu([int $contactId = NULL ]) : array<string|int, mixed>
Parameters
$contactId : int = NULL
Return values
array<string|int, mixed>

Array of context menu for logged in user.

copyCustomFields()

Method that copies custom fields values from an old entity to a new one.

public copyCustomFields(int $entityID, int $newEntityID[, string $parentOperation = NULL ]) : mixed

Fixes bug CRM-19302, where if a custom field of File type was present, left both events using the same file, breaking download URL's for the old event.

Parameters
$entityID : int
$newEntityID : int
$parentOperation : string = NULL
Tags
todo

the goal here is to clean this up so that it works for any entity. Copy Generic already DOES some custom field stuff but it seems to be bypassed & perhaps less good than this (or this just duplicates it...)

copyGeneric()

Make a shallow copy of an object and all the fields in the object.

public static copyGeneric(string $daoName, array<string|int, mixed> $criteria[, array<string|int, mixed> $newData = NULL ][, string $fieldsFix = NULL ][, string $blockCopyOfDependencies = NULL ][, bool $blockCopyofCustomValues = FALSE ]) : CRM_Core_DAO|bool
Parameters
$daoName : string

Name of the dao.

$criteria : array<string|int, mixed>

Array of all the fields & values. on which basis to copy

$newData : array<string|int, mixed> = NULL

Array of all the fields & values. to be copied besides the other fields

$fieldsFix : string = NULL

Array of fields that you want to prefix/suffix/replace.

$blockCopyOfDependencies : string = NULL

Fields that you want to block from. getting copied

$blockCopyofCustomValues : bool = FALSE

Case when you don't want to copy the custom values set in a template as it will override/ignore the submitted custom values

Return values
CRM_Core_DAO|bool

the newly created copy of the object. False if none created.

copyValues()

Given an associative array of name/value pairs, extract all the values that belong to this object and initialize the object with said values

public copyValues(array<string|int, mixed> $params) : bool
Parameters
$params : array<string|int, mixed>

Array of name/value pairs to save.

Return values
bool

Did we copy all null values into the object

create()

Create contact.

public static & create(array<string|int, mixed> &$params[, bool $fixAddress = TRUE ][, bool $invokeHooks = TRUE ][, bool $skipDelete = FALSE ]) : CRM_Contact_BAO_Contact|CRM_Core_Error|null

takes an associative array and creates a contact object and all the associated derived objects (i.e. individual, location, email, phone etc)

This function is invoked from within the web form layer and also from the api layer

Parameters
$params : array<string|int, mixed>

(reference ) an assoc array of name/value pairs.

$fixAddress : bool = TRUE

If we need to fix address.

$invokeHooks : bool = TRUE

If we need to invoke hooks.

$skipDelete : bool = FALSE

Unclear parameter, passed to website create

Tags
throws
CRM_Core_Exception
throws
UnauthorizedException
Return values
CRM_Contact_BAO_Contact|CRM_Core_Error|null

Created or updated contribution object. We are deprecating returning an error in favour of exceptions

createProfileContact()

Add/edit/register contacts through profile.

public static createProfileContact(array<string|int, mixed> &$params[, array<string|int, mixed> $fields = [] ][, int $contactID = NULL ][, int $addToGroupID = NULL ][, int $ufGroupId = NULL ][, string $ctype = NULL ][, bool $visibility = FALSE ]) : int
Parameters
$params : array<string|int, mixed>

Array of profile fields to be edited/added.

$fields : array<string|int, mixed> = []

Array of fields from UFGroup.

$contactID : int = NULL

Id of the contact to be edited/added.

$addToGroupID : int = NULL

Specifies the default group to which contact is added.

$ufGroupId : int = NULL

Uf group id (profile id).

$ctype : string = NULL
$visibility : bool = FALSE

Basically lets us know where this request is coming from. if via a profile from web, we restrict what groups are changed

Tags
throws
CRM_Core_Exception
throws
UnauthorizedException
Return values
int

contact id created/edited

createSQLFilter()

Get SQL where clause for SQL filter syntax input parameters.

public static createSQLFilter(string $fieldName, array<string|int, mixed> $filter[, string $type = NULL ][, string $alias = NULL ][, bool $returnSanitisedArray = FALSE ]) : null|string|array<string|int, mixed>

SQL version of api function to assign filters to the DAO based on the syntax $field => array('IN' => array(4,6,9)) OR $field => array('LIKE' => array('%me%)) etc

Parameters
$fieldName : string

Name of fields.

$filter : array<string|int, mixed>

filter to be applied indexed by operator.

$type : string = NULL

type of field (not actually used - nor in api @todo ).

$alias : string = NULL

alternative field name ('as') @todo- not actually used.

$returnSanitisedArray : bool = FALSE

Return a sanitised array instead of a clause. this is primarily so we can add filters @ the api level to the Query object based fields

Tags
throws
Exception
Return values
null|string|array<string|int, mixed>

a string is returned if $returnSanitisedArray is not set, otherwise and Array or NULL depending on whether it is supported as yet

createTestObject()

Creates a test object, including any required objects it needs via recursion createOnly: only create in database, do not store or return the objects (useful for perf testing) ONLY USE FOR TESTING

public static createTestObject(string $daoName[, array<string|int, mixed> $params = [] ][, int $numObjects = 1 ][, bool $createOnly = FALSE ]) : object|array<string|int, mixed>|null
Parameters
$daoName : string
$params : array<string|int, mixed> = []
$numObjects : int = 1
$createOnly : bool = FALSE
Return values
object|array<string|int, mixed>|null

NULL if $createOnly. A single object if $numObjects==1. Otherwise, an array of multiple objects.

createTriggers()

public static createTriggers(array<string|int, mixed> &$info[, string $onlyTableName = NULL ]) : mixed
Parameters
$info : array<string|int, mixed>

per hook_civicrm_triggerInfo.

$onlyTableName : string = NULL

the specific table requiring a rebuild; or NULL to rebuild all tables.

debugPrint()

public static debugPrint([null $message = NULL ][, bool $printDAO = TRUE ]) : mixed
Parameters
$message : null = NULL
$printDAO : bool = TRUE

delete()

Deletes items from table which match current objects variables.

public delete([bool $useWhere = FALSE ]) : int|false

Returns the true on success

for example

Designed to be extended

$object = new mytable(); $object->ID=123; echo $object->delete(); // builds a conditon

$object = new mytable(); $object->whereAdd('age > 12'); $object->limit(1); $object->orderBy('age DESC'); $object->delete(true); // dont use object vars, use the conditions, limit and order.

Parameters
$useWhere : bool = FALSE

(optional) If DB_DATAOBJECT_WHEREADD_ONLY is passed in then we will build the condition only using the whereAdd's. Default is to build the condition only using the object parameters.

Return values
int|false

Int (No. of rows affected) on success, false on failure, 0 on no data affected

deleteContact()

Delete a contact and all its associated records.

public static deleteContact(int $id[, bool $restore = FALSE ][, bool $skipUndelete = FALSE ][, bool $checkPermissions = TRUE ]) : bool
Parameters
$id : int

Id of the contact to delete.

$restore : bool = FALSE

Whether to actually restore, not delete.

$skipUndelete : bool = FALSE

Whether to force contact delete or not.

$checkPermissions : bool = TRUE
Tags
throws
CRM_Core_Exception
Return values
bool

Was contact deleted?

deleteContactImage()

Delete the image of a contact.

public static deleteContactImage(int $id) : bool
Parameters
$id : int

Id of the contact.

Return values
bool

Was contact image deleted?

deleteEntityContact()

Unused function.

public static deleteEntityContact(mixed $daoName, mixed $contactId) : mixed

in 5.47 will be removed in 5.80

Parameters
$daoName : mixed
$contactId : mixed

deleteRecord()

Delete a record from supplied params.

public static deleteRecord(array<string|int, mixed> $record) : static
Parameters
$record : array<string|int, mixed>

'id' is required.

Tags
throws
CRM_Core_Exception
Return values
static

deleteRecords()

Bulk delete multiple records.

public static deleteRecords(array<string|int, array<string|int, mixed>> $records) : array<string|int, static>
Parameters
$records : array<string|int, array<string|int, mixed>>
Tags
throws
CRM_Core_Exception
Return values
array<string|int, static>

deleteTestObjects()

Deletes the this object plus any dependent objects that are associated with it.

public static deleteTestObjects(string $daoName[, array<string|int, mixed> $params = [] ]) : mixed

ONLY USE FOR TESTING

Parameters
$daoName : string
$params : array<string|int, mixed> = []

disableFullGroupByMode()

Disables usage of the ONLY_FULL_GROUP_BY Mode if necessary

public static disableFullGroupByMode() : mixed

displayName()

Get the display name of a contact.

public static displayName(int $id) : null|string
Parameters
$id : int

Id of the contact.

Return values
null|string

display name of the contact if found

dropAllTables()

Drop all CiviCRM tables.

public static dropAllTables() : mixed
Tags
throws
CRM_Core_Exception

dropTriggers()

Wrapper function to drop triggers.

public static dropTriggers([string $tableName = NULL ]) : mixed
Parameters
$tableName : string = NULL

the specific table requiring a rebuild; or NULL to rebuild all tables.

ensureGreetingParamsAreSet()

Ensure greeting parameters are set.

public static ensureGreetingParamsAreSet(array<string|int, mixed> &$params) : mixed

By always populating greetings here we can be sure they are set if required & avoid a call later. (ie. knowing we have definitely tried disambiguates between NULL & not loaded.)

Parameters
$params : array<string|int, mixed>
Tags
throws
CRM_Core_Exception

escapeString()

public static escapeString(mixed $string) : string
Parameters
$string : mixed
Return values
string

escapeStrings()

Escape a list of strings for use with "WHERE X IN (...)" queries.

public static escapeStrings(array<string|int, mixed> $strings[, string $default = NULL ]) : string
Parameters
$strings : array<string|int, mixed>
$default : string = NULL

the value to use if $strings has no elements.

Return values
string

eg "abc","def","ghi"

escapeWildCardString()

public static escapeWildCardString(mixed $string) : string
Parameters
$string : mixed
Return values
string

executeQuery()

Execute a query.

public static & executeQuery(string $query[, array<string|int, mixed> $params = [] ][, bool $abort = TRUE ][, null $daoName = NULL ][, bool $freeDAO = FALSE ][, bool $i18nRewrite = TRUE ][, bool $trapException = FALSE ][, array<string|int, mixed> $options = [] ]) : CRM_Core_DAO|object
Parameters
$query : string

Query to be executed.

$params : array<string|int, mixed> = []
$abort : bool = TRUE
$daoName : null = NULL
$freeDAO : bool = FALSE
$i18nRewrite : bool = TRUE
$trapException : bool = FALSE
$options : array<string|int, mixed> = []
Tags
throws
DBQueryException
Return values
CRM_Core_DAO|object

object that holds the results of the query NB - if this is defined as just returning a DAO phpstorm keeps pointing out all the properties that are not part of the DAO

executeUnbufferedQuery()

Execute an unbuffered query.

public static executeUnbufferedQuery(string $query[, array<string|int, mixed> $params = [] ][, bool $abort = TRUE ][, null $daoName = NULL ][, bool $freeDAO = FALSE ][, bool $i18nRewrite = TRUE ][, bool $trapException = FALSE ]) : CRM_Core_DAO

This is a wrapper around new functionality exposed with CRM-17748.

Parameters
$query : string

query to be executed

$params : array<string|int, mixed> = []
$abort : bool = TRUE
$daoName : null = NULL
$freeDAO : bool = FALSE
$i18nRewrite : bool = TRUE
$trapException : bool = FALSE
Return values
CRM_Core_DAO

Object that points to an unbuffered result set

export()

Returns the list of fields that can be exported

public static export([bool $prefix = FALSE ]) : array<string|int, mixed>
Parameters
$prefix : bool = FALSE
Return values
array<string|int, mixed>

exportableFields()

Combine all the exportable fields from the lower levels object.

public static & exportableFields([int|string $contactType = 'Individual' ][, bool $status = FALSE ][, bool $export = FALSE ][, bool $search = FALSE ][, bool $withMultiRecord = FALSE ][, bool $checkPermissions = TRUE ]) : array<string|int, mixed>

Currently we are using importable fields as exportable fields

Parameters
$contactType : int|string = 'Individual'

contact Type

$status : bool = FALSE

True while exporting primary contacts.

$export : bool = FALSE

True when used during export.

$search : bool = FALSE

True when used during search, might conflict with export param?.

$withMultiRecord : bool = FALSE
$checkPermissions : bool = TRUE
Return values
array<string|int, mixed>

array of exportable Fields

fetchAll()

Returns all results as array-encoded records.

public fetchAll([mixed $k = FALSE ][, mixed $v = FALSE ][, mixed $method = FALSE ]) : array<string|int, mixed>
Parameters
$k : mixed = FALSE
$v : mixed = FALSE
$method : mixed = FALSE
Return values
array<string|int, mixed>

fetchGenerator()

Return the results as PHP generator.

public fetchGenerator([string $type = 'dao' ]) : mixed
Parameters
$type : string = 'dao'

Whether the generator yields 'dao' objects or 'array's.

fetchMap()

Get all the result records as mapping between columns.

public fetchMap(string $keyColumn, string $valueColumn) : array<string|int, mixed>
Parameters
$keyColumn : string

Ex: "name"

$valueColumn : string

Ex: "label"

Return values
array<string|int, mixed>

Ex: ["foo" => "The Foo Bar", "baz" => "The Baz Qux"]

fetchValue()

Returns a singular value.

public fetchValue() : mixed|null
Return values
mixed|null

fieldKeys()

Return a mapping from field-name to the corresponding key (as used in fields()).

public static fieldKeys() : array<string|int, mixed>
Return values
array<string|int, mixed>

[string $name => string $uniqueName]

fields()

Returns all the column names of this table.

public static & fields() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

fillValues()

Given an incomplete record, attempt to fill missing field values from the database

public static fillValues(array<string|int, mixed> $existingValues, mixed $fieldsToRetrieve) : array<string|int, mixed>
Parameters
$existingValues : array<string|int, mixed>
$fieldsToRetrieve : mixed
Return values
array<string|int, mixed>

findById()

Find a DAO object for the given ID and return it.

public static findById(int $id) : static
Parameters
$id : int

Id of the DAO object being searched for.

Tags
throws
Exception
Return values
static

Object of the type of the class that called this function.

findDuplicates()

public static findDuplicates(array<string|int, mixed> $dedupeParams[, array<string|int, mixed> $contextParams = [] ]) : array<string|int, mixed>
Parameters
$dedupeParams : array<string|int, mixed>
$contextParams : array<string|int, mixed> = []
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

findReferences()

Find all records which refer to this entity.

public findReferences() : array<string|int, CRM_Core_DAO>
Return values
array<string|int, CRM_Core_DAO>

formatFieldValues()

Format field values according to fields() metadata.

public static formatFieldValues(array<string|int, mixed> &$fieldValues) : void

When fetching results from a query, every field is returned as a string. This function automatically converts them to the correct data type.

Parameters
$fieldValues : array<string|int, mixed>

formatProfileContactParams()

Format profile contact parameters.

public static formatProfileContactParams(array<string|int, mixed> &$params, array<string|int, mixed> $fields[, int|null $contactID = NULL ][, int|null $ufGroupId = NULL ][, string|null $ctype = NULL ][, bool $skipCustom = FALSE ]) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>
$fields : array<string|int, mixed>
$contactID : int|null = NULL
$ufGroupId : int|null = NULL
$ctype : string|null = NULL
$skipCustom : bool = FALSE
Return values
array<string|int, mixed>

freeResult()

public static freeResult([null $ids = NULL ]) : mixed
Parameters
$ids : null = NULL

getAttribute()

Get the size and maxLength attributes for this text field.

public static getAttribute(string $class[, string $fieldName = NULL ]) : array<string|int, mixed>

(or for all text fields) in the DAO object.

Parameters
$class : string

Name of DAO class.

$fieldName : string = NULL

Field that i'm interested in or null if. you want the attributes for all DAO text fields

Return values
array<string|int, mixed>

assoc array of name => attribute pairs

getConnection()

public static getConnection() : DB_common
Return values
DB_common

getContactDetails()

Get the display name, primary email and location type of a contact.

public static getContactDetails(int $id) : array<string|int, mixed>
Parameters
$id : int

Id of the contact.

Return values
array<string|int, mixed>

Array of display_name, email if found, do_not_email or (null,null,null)

getContactIDsFromComponent()

Given the component id, compute the contact id since its used for things like send email

public static getContactIDsFromComponent(mixed $componentIDs, string $tableName[, string $idField = 'id' ]) : array<string|int, mixed>
Parameters
$componentIDs : mixed
$tableName : string
$idField : string = 'id'
Return values
array<string|int, mixed>

getContactSubType()

Get contact sub type for a contact.

public static getContactSubType(int $id[, string $implodeDelimiter = NULL ]) : string
Parameters
$id : int

Id of the contact whose contact sub type is needed.

$implodeDelimiter : string = NULL
Return values
string

contact_sub_type if $id found else null ""

getContactType()

Get contact type for a contact.

public static getContactType(int $id) : string
Parameters
$id : int

Id of the contact whose contact type is needed.

Return values
string

contact_type if $id found else null ""

getContactTypes()

Get pair of contact-type and sub-type for a contact.

public static getContactTypes(int $id) : array<string|int, mixed>
Parameters
$id : int

Id of the contact whose contact sub/contact type is needed.

Return values
array<string|int, mixed>

getCountComponent()

Provides counts for the contact summary tabs.

public static getCountComponent(string $type, int $contactId[, string|null $tableName = NULL ]) : int|false
Parameters
$type : string

Type of record to count.

$contactId : int

Input contact id.

$tableName : string|null = NULL

Deprecated - do not use

Return values
int|false

total number in database

getDatabaseName()

Get the name of the CiviCRM database.

public static getDatabaseName() : string

use mysql DATABASE() within the query.

Return values
string

getDbVal()

Fetch a single field value from the database.

public static getDbVal(string $returnColumn, string|int $searchValue[, string $searchColumn = 'id' ]) : array<string|int, mixed>|bool|int|string|null

Uses static caching and applies formatting.

Parameters
$returnColumn : string
$searchValue : string|int
$searchColumn : string = 'id'
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>|bool|int|string|null

Returned value will be formatted according to data type.

getDefaultFallbackValues()

Callback for `default_fallback` field values

public static getDefaultFallbackValues(array<string|int, mixed> $record, string $entityName, string $fieldName, array<string|int, mixed> $field) : mixed
Parameters
$record : array<string|int, mixed>
$entityName : string
$fieldName : string
$field : array<string|int, mixed>

getDisplayAndImage()

Get the display name and image of a contact.

public static getDisplayAndImage(int $id[, bool $includeTypeInReturnParameters = FALSE ]) : array<string|int, mixed>|null
Parameters
$id : int

The contactId.

$includeTypeInReturnParameters : bool = FALSE

Should type be part of the returned array?

Return values
array<string|int, mixed>|null

the displayName and contactImage for this contact

getDuplicateContacts()

Get any existing duplicate contacts based on the input parameters.

public static getDuplicateContacts(array<string|int, mixed> $input, string $contactType[, string $rule = 'Unsupervised' ][, mixed $excludedContactIDs = [] ][, bool $checkPermissions = TRUE ][, int $ruleGroupID = NULL ][, array<string|int, mixed> $contextParams = [] ]) : array<string|int, mixed>
Parameters
$input : array<string|int, mixed>

Input parameters to be matched.

$contactType : string
$rule : string = 'Unsupervised'
  • Supervised
  • Unsupervised
$excludedContactIDs : mixed = []

An array of ids not to be included in the results.

$checkPermissions : bool = TRUE
$ruleGroupID : int = NULL

ID of the rule group to be used if an override is desirable.

$contextParams : array<string|int, mixed> = []

The context if relevant, eg. ['event_id' => X]

Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

getDynamicReferencesToTable()

Get all dynamic references to the given table.

public static getDynamicReferencesToTable(string $tableName) : array<string|int, mixed>
Parameters
$tableName : string
Return values
array<string|int, mixed>

getEntityDescription()

Returns user-friendly description of this entity.

public static getEntityDescription() : string|null
Tags
inheritDoc
Return values
string|null

getEntityIcon()

Get icon for a particular contact.

public static getEntityIcon(string $entityName[, int|null $entityId = NULL ]) : string|null

Example: CRM_Contact_BAO_Contact::getIcon('Contact', 123)

Parameters
$entityName : string

Always "Contact".

$entityId : int|null = NULL

Id of the contact.

Tags
throws
CRM_Core_Exception
Return values
string|null

getEntityPaths()

Returns system paths related to this entity (as defined in the xml schema)

public static getEntityPaths() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>
public static getEntityRefCreateLinks([array<string|int, mixed> $appendProfiles = [] ]) : array<string|int, mixed>|false
Parameters
$appendProfiles : array<string|int, mixed> = []

Name of profile(s) to append to each link.

Return values
array<string|int, mixed>|false

getEntityRefFilters()

public static getEntityRefFilters() : array<string|int, mixed>
Return values
array<string|int, mixed>

getEntityTitle()

Returns localized title of this entity.

public static getEntityTitle([mixed $plural = FALSE ]) : string
Parameters
$plural : mixed = FALSE
Return values
string

getExportableFieldsWithPseudoConstants()

Get exportable fields with pseudoconstants rendered as an extra field.

public static getExportableFieldsWithPseudoConstants(string $baoClass) : array<string|int, mixed>
Parameters
$baoClass : string
Return values
array<string|int, mixed>

getExtensionName()

Get name of extension in which this DAO is defined.

public static getExtensionName() : string|null
Tags
inheritDoc
Return values
string|null

getFieldSpec()

public getFieldSpec(string $fieldName) : bool|array<string|int, mixed>
Parameters
$fieldName : string
Return values
bool|array<string|int, mixed>

getFieldValue()

Given a DAO name, a column name and a column value, find the record and GET the value of another column in that record

public static getFieldValue(string $daoName, int $searchValue[, string $returnColumn = 'name' ][, string $searchColumn = 'id' ][, bool $force = FALSE ]) : string|int|null
Parameters
$daoName : string

Name of the DAO (Example: CRM_Contact_DAO_Contact to retrieve value from a contact).

$searchValue : int

Value of the column you want to search by.

$returnColumn : string = 'name'

Name of the column you want to GET the value of.

$searchColumn : string = 'id'

Name of the column you want to search by.

$force : bool = FALSE

Skip use of the cache.

Tags
throws
CRM_Core_Exception
Return values
string|int|null

Value of $returnColumn in the retrieved record

getFirstDuplicateContact()

Get the first duplicate contacts based on the input parameters.

public static getFirstDuplicateContact(array<string|int, mixed> $input, string $contactType[, string $rule = 'Unsupervised' ][, mixed $excludedContactIDs = [] ][, bool $checkPermissions = TRUE ][, int $ruleGroupID = NULL ][, array<string|int, mixed> $contextParams = [] ]) : int|null
Parameters
$input : array<string|int, mixed>

Input parameters to be matched.

$contactType : string
$rule : string = 'Unsupervised'
  • Supervised
  • Unsupervised
$excludedContactIDs : mixed = []

An array of ids not to be included in the results.

$checkPermissions : bool = TRUE
$ruleGroupID : int = NULL

ID of the rule group to be used if an override is desirable.

$contextParams : array<string|int, mixed> = []

The context if relevant, eg. ['event_id' => X]

Return values
int|null

getGlobalSetting()

Lookup the value of a MySQL global configuration variable.

public static getGlobalSetting(string $name[, mixed $default = NULL ]) : mixed
Parameters
$name : string

E.g. "thread_stack".

$default : mixed = NULL

getHierContactDetails()

Get the all contact details (Hierarchical).

public static getHierContactDetails(int $contactId, array<string|int, mixed> $fields) : array<string|int, mixed>
Parameters
$contactId : int

Contact id.

$fields : array<string|int, mixed>

Fields array.

Return values
array<string|int, mixed>

Contact details

getLabelField()

public static getLabelField() : string|null
Return values
string|null

getLocaleTableName()

Get localized name of this table, if applicable.

public static getLocaleTableName([string|null $tableName = NULL ]) : string

If this is a multi-language installation and the table has localized columns, will return table name with language string appended, which points to a sql view. Otherwise, this returns the same output as

Parameters
$tableName : string|null = NULL

Unnecessary deprecated param

Tags
see
self::getTableName()
Return values
string

getLocBlockIds()

Retrieve loc block ids w/ given condition.

public static getLocBlockIds(int $contactId[, array<string|int, mixed> $criteria = [] ][, string $condOperator = 'AND' ]) : array<string|int, mixed>
Parameters
$contactId : int

Contact id.

$criteria : array<string|int, mixed> = []

Key => value pair which should be. fulfill by return record ids.

$condOperator : string = 'AND'

Operator use for grouping multiple conditions.

Return values
array<string|int, mixed>

loc block ids which fulfill condition.

getLog()

Returns if this table needs to be logged

public getLog() : bool
Tags
inheritDoc
Return values
bool

getMasterDisplayName()

Retrieve display name of contact that address is shared.

public static getMasterDisplayName([int $masterAddressId = NULL ][, int $contactId = NULL ]) : string|null

This is based on $masterAddressId or $contactId .

Parameters
$masterAddressId : int = NULL

Master id.

$contactId : int = NULL

Contact id. (deprecated - do not use)

Return values
string|null

the found display name or null.

getOptionLabels()

Populate option labels for this object's fields.

public getOptionLabels() : mixed
Tags
throws
exception

if called directly on the base class

getPrimaryEmail()

Get primary email of the contact.

public static getPrimaryEmail(int $contactID[, bool $polite = FALSE ]) : string
Parameters
$contactID : int

Contact id.

$polite : bool = FALSE

Whether to only pull an email if it's okay to send to it--that is, if it is not on_hold and the contact is not do_not_email.

Return values
string

Email address if present else null

getPrimaryLocationType()

Return the primary location type of a contact.

public static getPrimaryLocationType(int $contactId[, bool $skipDefaultPrimary = FALSE ][, string|null $block = NULL ]) : int|null

$params int $contactId contact_id $params boolean $isPrimaryExist if true, return primary contact location type otherwise null $params boolean $skipDefaultPrimary if true, return primary contact location type otherwise null

Parameters
$contactId : int
$skipDefaultPrimary : bool = FALSE
$block : string|null = NULL
Return values
int|null

$locationType location_type_id

getReferenceCounts()

public getReferenceCounts() : array<string|int, array{name: string, type: string, count: int, table: string|null, key: string|null}>
Return values
array<string|int, array{name: string, type: string, count: int, table: string|null, key: string|null}>

each item has keys:

  • name: string
  • type: string
  • count: int
  • table: string|null SQL table name
  • key: string|null SQL column name

getReferencesToContactTable()

Get all references to contact table.

public static getReferencesToContactTable() : mixed

This includes core tables, custom group tables, tables added by the merge hook and the entity_tag table.

Refer to CRM-17454 for information on the danger of querying the information schema to derive this.

Tags
throws
CRM_Core_Exception

getReferencesToTable()

List all tables which have either: - hard foreign keys to this table, or - a dynamic foreign key that includes this table as a possible target.

public static getReferencesToTable(string $tableName) : array<string|int, CRM_Core_Reference_Interface>
Parameters
$tableName : string

Table referred to.

Return values
array<string|int, CRM_Core_Reference_Interface>

structure of table and column, listing every table with a foreign key reference to $tableName, and the column where the key appears.

getSelectWhereClause()

This returns the final permissioned query string for this entity

public static getSelectWhereClause([string|null $tableAlias = NULL ][, string|null $entityName = NULL ][, array<string|int, mixed> $conditions = [] ]) : array<string|int, mixed>

With acls from related entities + additional clauses from hook_civicrm_selectWhereClause

DO NOT OVERRIDE THIS FUNCTION

Parameters
$tableAlias : string|null = NULL
$entityName : string|null = NULL
$conditions : array<string|int, mixed> = []

Values from WHERE or ON clause

Tags
TODO:

ADD final keyword to function signature

Return values
array<string|int, mixed>

getSortString()

Unused function.

public static getSortString(mixed $sort[, mixed $default = NULL ]) : mixed

in 5.72 will be removed in 5.85

Parameters
$sort : mixed
$default : mixed = NULL

getSupportedFields()

Returns all usable fields, indexed by name.

public static getSupportedFields([bool $checkPermissions = FALSE ]) : array<string|int, mixed>

This function differs from fields() in that it indexes by name rather than unique_name.

It excludes fields not added yet by pending upgrades. This avoids problems with trying to SELECT a field that exists in code but has not yet been added to the db.

Parameters
$checkPermissions : bool = FALSE

Filter by field permissions.

Return values
array<string|int, mixed>

getTableName()

Returns the name of this table

public static getTableName() : string
Tags
inheritDoc
Return values
string

getTableNames()

Gets the names of all enabled schema tables.

public static getTableNames() : array<string|int, mixed>
  • Includes tables from core, components & enabled extensions.
  • Excludes log tables, temp tables, and missing/disabled extensions.
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

getThumbSize()

Return proportional height and width of the image.

public static getThumbSize(int $imageWidth, int $imageHeight) : array<string|int, mixed>
Parameters
$imageWidth : int

Width of image.

$imageHeight : int

Height of image.

Return values
array<string|int, mixed>

Thumb dimension of image

getTimestamps()

Get the creation/modification times for a contact.

public static getTimestamps(int $contactId) : array<string|int, mixed>
Parameters
$contactId : int
Return values
array<string|int, mixed>

Dates - ('created_date' => $, 'modified_date' => $)

getValues()

Fetch the object and store the values in the values array.

public static getValues(array<string|int, mixed> $params, array<string|int, mixed> &$values) : CRM_Contact_BAO_Contact|null

avoid this function, no planned removed at this stage as there are still core callers.

Parameters
$params : array<string|int, mixed>

Input parameters to find object.

$values : array<string|int, mixed>

Output values of the object.

Return values
CRM_Contact_BAO_Contact|null

The found object or null

hasName()

Check if a contact has a name.

public static hasName(array<string|int, mixed> $contact) : bool
  • Individuals need a first_name or last_name
  • Organizations need organization_name
  • Households need household_name
Parameters
$contact : array<string|int, mixed>
Return values
bool

import()

Returns the list of fields that can be imported

public static import([bool $prefix = FALSE ]) : array<string|int, mixed>
Parameters
$prefix : bool = FALSE
Return values
array<string|int, mixed>

importableFields()

Combine all the importable fields from the lower levels object.

public static importableFields([int|string $contactType = 'Individual' ][, bool $status = FALSE ][, bool $showAll = FALSE ][, bool $isProfile = FALSE ][, bool $checkPermission = TRUE ][, bool $withMultiCustomFields = FALSE ]) : array<string|int, mixed>

The ordering is important, since currently we do not have a weight scheme. Adding weight is super important

Parameters
$contactType : int|string = 'Individual'

contact Type

$status : bool = FALSE

Status is used to manipulate first title.

$showAll : bool = FALSE

If true returns all fields (includes disabled fields).

$isProfile : bool = FALSE

If its profile mode.

$checkPermission : bool = TRUE

If false, do not include permissioning clause (for custom data).

$withMultiCustomFields : bool = FALSE
Return values
array<string|int, mixed>

array of importable Fields

indices()

public static indices([bool $localize = TRUE ]) : array<string|int, mixed>
Parameters
$localize : bool = TRUE
Tags
inheritDoc
Return values
array<string|int, mixed>

init()

Initialize the DAO object.

public static init(string $dsn) : mixed
Parameters
$dsn : string

The database connection string.

initialize()

Initialization for all DAO objects. Since we access DB_DO programatically we need to set the links manually.

public initialize() : mixed

isComponentEnabled()

Check if component is enabled for this DAO class

public static isComponentEnabled() : bool
Return values
bool

isDBMyISAM()

public static isDBMyISAM([int $maxTablesToCheck = 10 ]) : bool
Parameters
$maxTablesToCheck : int = 10
Return values
bool

isFieldHasLocationType()

Check if a field is associated with an entity that has a location type.

public static isFieldHasLocationType(string $fieldTitle) : bool

(ie. is an address, phone, email etc field).

Parameters
$fieldTitle : string

Title of the field (not the name - create a new function for that if required).

Return values
bool

isValidOption()

Wrapper to validate internal DAO options before passing to DB_mysql/DB_Common level

public isValidOption(array<string|int, mixed> $options) : bool
Parameters
$options : array<string|int, mixed>
Return values
bool

Provided options are valid

keys()

Returns primary keys (usually ['id'])

public keys() : array<string|int, string>
Tags
inheritDoc
Return values
array<string|int, string>

log()

public log([bool $created = FALSE ]) : mixed
Parameters
$created : bool = FALSE

makeAttribute()

Create an attribute for this specific field. We only do this for strings and text

public static makeAttribute(array<string|int, mixed> $field) : array<string|int, mixed>|null
Parameters
$field : array<string|int, mixed>

The field under task.

Return values
array<string|int, mixed>|null

the attributes for the object

makeHierReturnProperties()

Given a set of flat profile style field names, create a hierarchy.

public static & makeHierReturnProperties(array<string|int, mixed> $fields[, int $contactId = NULL ]) : array<string|int, mixed>

This is for the query to use, create the right sql.

Parameters
$fields : array<string|int, mixed>
$contactId : int = NULL

Contact id.

Return values
array<string|int, mixed>

A hierarchical property tree if appropriate

matchContactOnEmail()

Find the get contact details.

public static matchContactOnEmail(string $mail[, string $ctype = NULL ]) : object|null

This function does not respect ACLs for now, which might need to be rectified at some stage based on how its used.

Parameters
$mail : string

Primary email address of the contact.

$ctype : string = NULL

Contact type.

Return values
object|null

$dao contact details

matchContactOnOpenId()

Find the contact details associated with an OpenID.

public static matchContactOnOpenId(string $openId[, string $ctype = NULL ]) : object|null
Parameters
$openId : string

OpenId of the contact.

$ctype : string = NULL

Contact type.

Return values
object|null

$dao contact details

objectExists()

Check if there is a record with the same name in the db.

public static objectExists(string $value, string $daoName, string $daoID[, string $fieldName = 'name' ][, string $domainID = NULL ]) : bool
Parameters
$value : string

The value of the field we are checking.

$daoName : string

The dao object name.

$daoID : string

The id of the object being updated. u can change your name. as long as there is no conflict

$fieldName : string = 'name'

The name of the field in the DAO.

$domainID : string = NULL

The id of the domain. Object exists only for the given domain.

Return values
bool

true if object exists

on_hook_civicrm_post()

Event fired after modifying any entity.

public static on_hook_civicrm_post(PostEvent $event) : mixed
Parameters
$event : PostEvent

processImage()

Extract contact id from url for deleting contact image.

public static processImage() : mixed

processImageParams()

Validate type of contact image.

public static processImageParams(array<string|int, mixed> &$params[, string $imageIndex = 'image_URL' ][, string $statusMsg = NULL ][, string $opType = 'status' ]) : bool
Parameters
$params : array<string|int, mixed>
$imageIndex : string = 'image_URL'

Index of image field.

$statusMsg : string = NULL

Status message to be set after operation.

$opType : string = 'status'

Type of operation like fatal, bounce etc.

Return values
bool

true if valid image extension

query()

Execute a query by the current DAO, localizing it along the way (if needed).

public query(string $query[, bool $i18nRewrite = TRUE ]) : object
Parameters
$query : string

The SQL query for execution.

$i18nRewrite : bool = TRUE

Whether to rewrite the query.

Return values
object

the current DAO object after the query execution

reenableFullGroupByMode()

Re-enables ONLY_FULL_GROUP_BY sql_mode as necessary.

public static reenableFullGroupByMode() : mixed

.

requireSafeDBName()

ensure database name is 'safe', i.e. only contains word characters (includes underscores) and dashes, and contains at least one [a-z] case insensitive.

public static requireSafeDBName(mixed $database) : bool
Parameters
$database : mixed
Return values
bool

reset()

Reset the DAO object.

public reset() : mixed

DAO is kinda crappy in that there is an unwritten rule of one query per DAO.

We attempt to get around this crappy restriction by resetting some of DAO's internal fields. Use this with caution

retrieve()

Fetch object based on array of properties.

public static & retrieve(array<string|int, mixed> &$params[, array<string|int, mixed> &$defaults = [] ][, bool $microformat = FALSE ]) : CRM_Contact_BAO_Contact

This is called from a few places but creates rather than solves complexity.

Parameters
$params : array<string|int, mixed>

(reference ) an assoc array of name/value pairs.

$defaults : array<string|int, mixed> = []

(reference ) an assoc array to hold the name / value pairs. in a hierarchical manner

$microformat : bool = FALSE

For location in microformat.

Return values
CRM_Contact_BAO_Contact

schemaRequiresRebuilding()

Checks if CONSTRAINT keyword exists for a specified table.

public static schemaRequiresRebuilding([mixed $tables = ["civicrm_contact"] ]) : mixed

in 5.72 will be removed in 5.85

Parameters
$tables : mixed = ["civicrm_contact"]

sequenceKey()

Tells DB_DataObject which keys use autoincrement.

public sequenceKey() : array<string|int, mixed>

'id' is autoincrementing by default.

FIXME: this should return all autoincrement keys not just the first.

Return values
array<string|int, mixed>

serializeField()

Transform an array to a serialized string for database storage.

public static serializeField(array<string|int, mixed>|null $value, int $serializationType) : string|null
Parameters
$value : array<string|int, mixed>|null
$serializationType : int
Tags
throws
Exception
Return values
string|null

setApiFilter()

public setApiFilter(array<string|int, mixed> &$params) : mixed
Parameters
$params : array<string|int, mixed>

setCreateDefaults()

Set defaults when creating new entity.

public static setCreateDefaults(array<string|int, mixed> &$params, mixed $defaults) : mixed

(don't call this set defaults as already in use with different signature in some places)

Parameters
$params : array<string|int, mixed>
$defaults : mixed

setFieldValue()

Given a DAO name, a column name and a column value, find the record and SET the value of another column in that record

public static setFieldValue(string $daoName, int $searchValue, string $setColumn, string $setValue[, string $searchColumn = 'id' ]) : bool
Parameters
$daoName : string

Name of the DAO (Example: CRM_Contact_DAO_Contact to retrieve value from a contact).

$searchValue : int

Value of the column you want to search by.

$setColumn : string

Name of the column you want to SET the value of.

$setValue : string

SET the setColumn to this value.

$searchColumn : string = 'id'

Name of the column you want to search by.

Return values
bool

true if we found and updated the object, else false

setOptions()

https://issues.civicrm.org/jira/browse/CRM-17748 Sets the internal options to be used on a query

public setOptions(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>

shortenSQLName()

SQL has a limit of 64 characters on various names: table name, trigger name, column name ... For custom groups and fields we generated names from user entered input which can be longer than this length, this function helps with creating strings that meet various criteria.

public static shortenSQLName(string $string[, int $length = 60 ][, bool $makeRandom = FALSE ]) : string
Parameters
$string : string

The string to be shortened.

$length : int = 60

The max length of the string.

$makeRandom : bool = FALSE
Return values
string

singleValueQuery()

Execute a query and get the single result.

public static & singleValueQuery(string $query[, array<string|int, mixed> $params = [] ][, bool $abort = TRUE ][, bool $i18nRewrite = TRUE ]) : string|null
Parameters
$query : string

Query to be executed.

$params : array<string|int, mixed> = []
$abort : bool = TRUE
$i18nRewrite : bool = TRUE
Tags
throws
CRM_Core_Exception
Return values
string|null

the result of the query if any

storeValues()

Store all the values from this object in an associative array this is a destructive store, calling function is responsible for keeping sanity of id's.

public static storeValues(object &$object, array<string|int, mixed> &$values) : mixed
Parameters
$object : object

The object that we are extracting data from.

$values : array<string|int, mixed>

(reference ) associative array of name/value pairs.

table()

Get/set an associative array of table columns

public table() : array<string|int, mixed>
Return values
array<string|int, mixed>

(associative)

tableHasBeenAdded()

Checks if this DAO's table ought to exist.

public static tableHasBeenAdded() : bool

If there are pending DB updates, this function compares the CiviCRM version of the table to the current schema version.

Tags
throws
CRM_Core_Exception
Return values
bool

triggerInfo()

Get a list of triggers for the contact table.

public static triggerInfo(array<string|int, mixed> &$info[, string|null $tableName = NULL ]) : mixed
Parameters
$info : array<string|int, mixed>
$tableName : string|null = NULL
Tags
see
http://issues.civicrm.org/jira/browse/CRM-10554
see
hook_civicrm_triggerInfo
see
CRM_Core_DAO::triggerRebuild

triggerRebuild()

Build a list of triggers via hook and add them to (err, reconcile them with) the database.

public static triggerRebuild([string $tableName = NULL ][, bool $force = FALSE ]) : mixed
Parameters
$tableName : string = NULL

the specific table requiring a rebuild; or NULL to rebuild all tables.

$force : bool = FALSE
Tags
see

CRM-9716

unSerializeField()

Transform a serialized string from the database into an array.

public static unSerializeField(string|null $value, mixed $serializationType) : array<string|int, mixed>|null
Parameters
$value : string|null
$serializationType : mixed
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>|null

unsetProtectedFields()

Format the output of the create contact function

public static unsetProtectedFields(array<string|int, CRM_Contact_DAO_Contact>|array<string|int, array<string|int, mixed>> &$contacts) : mixed
Parameters
$contacts : array<string|int, CRM_Contact_DAO_Contact>|array<string|int, array<string|int, mixed>>

updateContactCache()

Action to update any caches relating to a recently update contact.

public static updateContactCache(int $contactID[, bool $isTrashed = FALSE ]) : mixed

I was going to call this from delete as well as from create to ensure the delete is being done whenever a contact is set to is_deleted=1 BUT I found create is already over-aggressive in that regard so adding it to delete seems to be enough to remove it from CRM_Contact_BAO_Contact_Permission where the call involved a subquery that was locking the table.

Parameters
$contactID : int
$isTrashed : bool = FALSE

updateGreetingsOnTokenFieldChange()

Update contact greetings if an update has resulted in a custom field change.

public static updateGreetingsOnTokenFieldChange(array<string|int, mixed> $updatedFields, array<string|int, mixed> $contactParams) : mixed
Parameters
$updatedFields : array<string|int, mixed>

Array of fields that have been updated e.g array('first_name', 'prefix_id', 'custom_2');

$contactParams : array<string|int, mixed>

Parameters known about the contact. At minimum array('contact_id' => x). Fields in this array will take precedence over DB fields (so far only in the case of greeting id fields).

writeRecord()

Create or update a record from supplied params.

public static writeRecord(array<string|int, mixed> $record) : static

If 'id' is supplied, an existing record will be updated Otherwise a new record will be created.

Parameters
$record : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
Return values
static

writeRecords()

Bulk save multiple records

public static writeRecords(array<string|int, array<string|int, mixed>> $records) : array<string|int, static>
Parameters
$records : array<string|int, array<string|int, mixed>>
Tags
throws
CRM_Core_Exception
Return values
array<string|int, static>

_setDBOptions()

https://issues.civicrm.org/jira/browse/CRM-17748 wrapper to pass internal DAO options down to DB_mysql/DB_Common level

protected _setDBOptions(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>

assignTestFK()

protected assignTestFK(string $fieldName, mixed $fieldDef, array<string|int, mixed> $params) : mixed
Parameters
$fieldName : string
$fieldDef : mixed
$params : array<string|int, mixed>

assignTestValue()

Generate and assign an arbitrary value to a field of a test object.

protected assignTestValue(string $fieldName, array<string|int, mixed> &$fieldDef, int $counter) : mixed
Parameters
$fieldName : string
$fieldDef : array<string|int, mixed>
$counter : int

The globally-unique ID of the test object.

Tags
throws
CRM_Core_Exception

copyLocalizable()

Method that copies localizable fields from an old entity to a new one.

protected copyLocalizable(int $entityID, int $newEntityID, array<string|int, mixed> $fieldsToPrefix, array<string|int, mixed> $fieldsToSuffix, array<string|int, mixed> $fieldsToReplace) : mixed

Fixes bug dev/core#2479, where non current locale fields are copied from current locale losing translation when copying

Parameters
$entityID : int
$newEntityID : int
$fieldsToPrefix : array<string|int, mixed>
$fieldsToSuffix : array<string|int, mixed>
$fieldsToReplace : array<string|int, mixed>

formatFieldValue()

Format a value according to field metadata.

protected static formatFieldValue(string|null $value, array<string|int, mixed>|null $fieldSpec) : mixed
Parameters
$value : string|null
$fieldSpec : array<string|int, mixed>|null

getDynamicFkAclClauses()

Get an array of ACL clauses for a dynamic FK (entity_id/entity_table combo)

protected static getDynamicFkAclClauses(string $entityTableField, string $entityIdField[, mixed|null $entityTableValues = NULL ]) : array<string|int, mixed>
Parameters
$entityTableField : string
$entityIdField : string
$entityTableValues : mixed|null = NULL
Return values
array<string|int, mixed>

getFirstPrimaryKey()

protected getFirstPrimaryKey() : string
Return values
string

getLocationEntityForKey()

Get the relevant location entity for the array key.

protected static getLocationEntityForKey(string $fieldName) : string

Based on the field name we determine which location entity we are dealing with. Apart from a few specific ones they are mostly 'address' (the default).

Parameters
$fieldName : string
Return values
string

getTableAddVersion()

protected static getTableAddVersion() : string
Tags
inheritDoc
Return values
string

Version in which table was added

resolveStateProvinceID()

Resolve a state province string (UT or Utah) to an ID.

protected static resolveStateProvinceID(array<string|int, mixed> $values, int|null $countryID) : int|null

If country has been passed in we should select a state belonging to that country.

Alternatively we should choose from enabled countries, prioritising the default country.

Parameters
$values : array<string|int, mixed>
$countryID : int|null
Tags
throws
CRM_Core_Exception
Return values
int|null

clearDbColumnValueCache()

Remove item from static cache during update/delete operations

private clearDbColumnValueCache() : mixed

getEntityDefinition()

private static getEntityDefinition() : array<string|int, mixed>
Return values
array<string|int, mixed>

getEntityInfo()

private static getEntityInfo() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFieldLength()

private static getFieldLength(mixed $sqlType) : string|null
Parameters
$sqlType : mixed
Return values
string|null

getSchemaFields()

private static getSchemaFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTemplateForGreeting()

Get the template string for the given greeting.

private static getTemplateForGreeting(string $greetingType, CRM_Contact_DAO_Contact $contact) : string
Parameters
$greetingType : string
$contact : CRM_Contact_DAO_Contact
Return values
string

loadSchemaFields()

private static loadSchemaFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

makeNameFromLabel()

When creating a record without a supplied name, create a unique, clean name derived from the label.

private makeNameFromLabel() : void

Note: this function does nothing unless a unique index exists for "name" column.

setDefaultsFromCallback()

Set default values for fields based on callback functions

private static setDefaultsFromCallback(string $entityName, array<string|int, mixed> &$record) : void
Parameters
$entityName : string

The entity name

$record : array<string|int, mixed>

The record array to set default values for


        
On this page

Search results