5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contact/RelationshipCache.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:f70f357cd7e45be254350f45ef41aee2)
13 * Database access object for the RelationshipCache entity.
15 class CRM_Contact_DAO_RelationshipCache
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '5.29';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_relationship_cache';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-handshake-o';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = FALSE;
41 * Paths for accessing this entity in the UI.
45 protected static $_paths = [
46 'view' => 'civicrm/contact/view/rel?action=view&reset=1&cid=[near_contact_id]&id=[relationship_id]',
47 'update' => 'civicrm/contact/view/rel?action=update&reset=1&cid=[near_contact_id]&id=[relationship_id]&rtype=[orientation]',
48 'delete' => 'civicrm/contact/view/rel?action=delete&reset=1&cid=[near_contact_id]&id=[relationship_id]',
52 * Relationship Cache ID
59 * id of the relationship (FK to civicrm_relationship.id)
63 public $relationship_id;
66 * id of the relationship type
70 public $relationship_type_id;
73 * The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.
80 * id of the first contact
84 public $near_contact_id;
87 * name for relationship of near_contact to far_contact.
91 public $near_relation;
94 * id of the second contact
98 public $far_contact_id;
101 * name for relationship of far_contact to near_contact.
105 public $far_relation;
108 * is the relationship active ?
115 * date when the relationship started
122 * date when the relationship ended
138 public function __construct() {
139 $this->__table
= 'civicrm_relationship_cache';
140 parent
::__construct();
144 * Returns localized title of this entity.
146 * @param bool $plural
147 * Whether to return the plural version of the title.
149 public static function getEntityTitle($plural = FALSE) {
150 return $plural ?
ts('Related Contacts') : ts('Related Contact');
154 * Returns foreign keys and entity references.
157 * [CRM_Core_Reference_Interface]
159 public static function getReferenceColumns() {
160 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
161 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
162 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
163 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
164 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'near_contact_id', 'civicrm_contact', 'id');
165 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'far_contact_id', 'civicrm_contact', 'id');
166 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_id', 'civicrm_case', 'id');
167 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
169 return Civi
::$statics[__CLASS__
]['links'];
173 * Returns all the column names of this table
177 public static function &fields() {
178 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
179 Civi
::$statics[__CLASS__
]['fields'] = [
182 'type' => CRM_Utils_Type
::T_INT
,
183 'title' => ts('Relationship Cache ID'),
184 'description' => ts('Relationship Cache ID'),
186 'where' => 'civicrm_relationship_cache.id',
187 'table_name' => 'civicrm_relationship_cache',
188 'entity' => 'RelationshipCache',
189 'bao' => 'CRM_Contact_BAO_RelationshipCache',
197 'relationship_id' => [
198 'name' => 'relationship_id',
199 'type' => CRM_Utils_Type
::T_INT
,
200 'title' => ts('Relationship ID'),
201 'description' => ts('id of the relationship (FK to civicrm_relationship.id)'),
203 'where' => 'civicrm_relationship_cache.relationship_id',
204 'table_name' => 'civicrm_relationship_cache',
205 'entity' => 'RelationshipCache',
206 'bao' => 'CRM_Contact_BAO_RelationshipCache',
208 'FKClassName' => 'CRM_Contact_DAO_Relationship',
210 'label' => ts("Relationship"),
215 'relationship_type_id' => [
216 'name' => 'relationship_type_id',
217 'type' => CRM_Utils_Type
::T_INT
,
218 'title' => ts('Relationship Type ID'),
219 'description' => ts('id of the relationship type'),
221 'where' => 'civicrm_relationship_cache.relationship_type_id',
222 'table_name' => 'civicrm_relationship_cache',
223 'entity' => 'RelationshipCache',
224 'bao' => 'CRM_Contact_BAO_RelationshipCache',
226 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
228 'label' => ts("Relationship Type"),
234 'name' => 'orientation',
235 'type' => CRM_Utils_Type
::T_STRING
,
236 'title' => ts('Orientation (a_b or b_a)'),
237 'description' => ts('The cache record is a permutation of the original relationship record. The orientation indicates whether it is forward (a_b) or reverse (b_a) relationship.'),
240 'size' => CRM_Utils_Type
::FOUR
,
241 'where' => 'civicrm_relationship_cache.orientation',
242 'table_name' => 'civicrm_relationship_cache',
243 'entity' => 'RelationshipCache',
244 'bao' => 'CRM_Contact_BAO_RelationshipCache',
246 'pseudoconstant' => [
247 'callback' => 'CRM_Core_SelectValues::relationshipOrientation',
252 'near_contact_id' => [
253 'name' => 'near_contact_id',
254 'type' => CRM_Utils_Type
::T_INT
,
255 'title' => ts('Contact ID (Near side)'),
256 'description' => ts('id of the first contact'),
258 'where' => 'civicrm_relationship_cache.near_contact_id',
259 'table_name' => 'civicrm_relationship_cache',
260 'entity' => 'RelationshipCache',
261 'bao' => 'CRM_Contact_BAO_RelationshipCache',
263 'FKClassName' => 'CRM_Contact_DAO_Contact',
265 'type' => 'EntityRef',
266 'label' => ts("Contact (Near side)"),
272 'name' => 'near_relation',
273 'type' => CRM_Utils_Type
::T_STRING
,
274 'title' => ts('Relationship Name (to related contact)'),
275 'description' => ts('name for relationship of near_contact to far_contact.'),
277 'size' => CRM_Utils_Type
::BIG
,
278 'where' => 'civicrm_relationship_cache.near_relation',
279 'table_name' => 'civicrm_relationship_cache',
280 'entity' => 'RelationshipCache',
281 'bao' => 'CRM_Contact_BAO_RelationshipCache',
284 'label' => ts("Relationship to contact"),
286 'pseudoconstant' => [
287 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
292 'far_contact_id' => [
293 'name' => 'far_contact_id',
294 'type' => CRM_Utils_Type
::T_INT
,
295 'title' => ts('Contact ID (Far side)'),
296 'description' => ts('id of the second contact'),
298 'where' => 'civicrm_relationship_cache.far_contact_id',
299 'table_name' => 'civicrm_relationship_cache',
300 'entity' => 'RelationshipCache',
301 'bao' => 'CRM_Contact_BAO_RelationshipCache',
303 'FKClassName' => 'CRM_Contact_DAO_Contact',
305 'type' => 'EntityRef',
306 'label' => ts("Contact (Far side)"),
312 'name' => 'far_relation',
313 'type' => CRM_Utils_Type
::T_STRING
,
314 'title' => ts('Relationship Name (from related contact)'),
315 'description' => ts('name for relationship of far_contact to near_contact.'),
317 'size' => CRM_Utils_Type
::BIG
,
318 'where' => 'civicrm_relationship_cache.far_relation',
319 'table_name' => 'civicrm_relationship_cache',
320 'entity' => 'RelationshipCache',
321 'bao' => 'CRM_Contact_BAO_RelationshipCache',
324 'label' => ts("Relationship from contact"),
326 'pseudoconstant' => [
327 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
333 'name' => 'is_active',
334 'type' => CRM_Utils_Type
::T_BOOLEAN
,
335 'title' => ts('Relationship Is Active'),
336 'description' => ts('is the relationship active ?'),
337 'where' => 'civicrm_relationship_cache.is_active',
339 'table_name' => 'civicrm_relationship_cache',
340 'entity' => 'RelationshipCache',
341 'bao' => 'CRM_Contact_BAO_RelationshipCache',
344 'type' => 'CheckBox',
349 'relationship_start_date' => [
350 'name' => 'start_date',
351 'type' => CRM_Utils_Type
::T_DATE
,
352 'title' => ts('Relationship Start Date'),
353 'description' => ts('date when the relationship started'),
354 'where' => 'civicrm_relationship_cache.start_date',
355 'table_name' => 'civicrm_relationship_cache',
356 'entity' => 'RelationshipCache',
357 'bao' => 'CRM_Contact_BAO_RelationshipCache',
360 'type' => 'Select Date',
361 'formatType' => 'activityDate',
366 'relationship_end_date' => [
367 'name' => 'end_date',
368 'type' => CRM_Utils_Type
::T_DATE
,
369 'title' => ts('Relationship End Date'),
370 'description' => ts('date when the relationship ended'),
371 'where' => 'civicrm_relationship_cache.end_date',
372 'table_name' => 'civicrm_relationship_cache',
373 'entity' => 'RelationshipCache',
374 'bao' => 'CRM_Contact_BAO_RelationshipCache',
377 'type' => 'Select Date',
378 'formatType' => 'activityDate',
385 'type' => CRM_Utils_Type
::T_INT
,
386 'title' => ts('Case ID'),
387 'description' => ts('FK to civicrm_case'),
388 'where' => 'civicrm_relationship_cache.case_id',
390 'table_name' => 'civicrm_relationship_cache',
391 'entity' => 'RelationshipCache',
392 'bao' => 'CRM_Contact_BAO_RelationshipCache',
394 'FKClassName' => 'CRM_Case_DAO_Case',
395 'component' => 'CiviCase',
397 'label' => ts("Case"),
403 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
405 return Civi
::$statics[__CLASS__
]['fields'];
409 * Return a mapping from field-name to the corresponding key (as used in fields()).
412 * Array(string $name => string $uniqueName).
414 public static function &fieldKeys() {
415 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
416 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
418 return Civi
::$statics[__CLASS__
]['fieldKeys'];
422 * Returns the names of this table
426 public static function getTableName() {
427 return self
::$_tableName;
431 * Returns if this table needs to be logged
435 public function getLog() {
440 * Returns the list of fields that can be imported
442 * @param bool $prefix
446 public static function &import($prefix = FALSE) {
447 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship_cache', $prefix, []);
452 * Returns the list of fields that can be exported
454 * @param bool $prefix
458 public static function &export($prefix = FALSE) {
459 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship_cache', $prefix, []);
464 * Returns the list of indices
466 * @param bool $localize
470 public static function indices($localize = TRUE) {
472 'UI_relationship' => [
473 'name' => 'UI_relationship',
475 0 => 'relationship_id',
478 'localizable' => FALSE,
480 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation',
482 'index_nearid_nearrelation' => [
483 'name' => 'index_nearid_nearrelation',
485 0 => 'near_contact_id',
486 1 => 'near_relation',
488 'localizable' => FALSE,
489 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation',
491 'index_nearid_farrelation' => [
492 'name' => 'index_nearid_farrelation',
494 0 => 'near_contact_id',
497 'localizable' => FALSE,
498 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation',
500 'index_near_relation' => [
501 'name' => 'index_near_relation',
503 0 => 'near_relation',
505 'localizable' => FALSE,
506 'sig' => 'civicrm_relationship_cache::0::near_relation',
509 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;