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:637d262d0fe18e30673e5d1b1317e4aa)
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
54 * @var int|string|null
55 * (SQL type: int unsigned)
56 * Note that values will be retrieved from the database as a string.
61 * id of the relationship (FK to civicrm_relationship.id)
64 * (SQL type: int unsigned)
65 * Note that values will be retrieved from the database as a string.
67 public $relationship_id;
70 * id of the relationship type
73 * (SQL type: int unsigned)
74 * Note that values will be retrieved from the database as a string.
76 public $relationship_type_id;
79 * 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.
83 * Note that values will be retrieved from the database as a string.
88 * id of the first contact
91 * (SQL type: int unsigned)
92 * Note that values will be retrieved from the database as a string.
94 public $near_contact_id;
97 * name for relationship of near_contact to far_contact.
100 * (SQL type: varchar(64))
101 * Note that values will be retrieved from the database as a string.
103 public $near_relation;
106 * id of the second contact
109 * (SQL type: int unsigned)
110 * Note that values will be retrieved from the database as a string.
112 public $far_contact_id;
115 * name for relationship of far_contact to near_contact.
118 * (SQL type: varchar(64))
119 * Note that values will be retrieved from the database as a string.
121 public $far_relation;
124 * is the relationship active ?
127 * (SQL type: tinyint)
128 * Note that values will be retrieved from the database as a string.
133 * date when the relationship started
137 * Note that values will be retrieved from the database as a string.
142 * date when the relationship ended
146 * Note that values will be retrieved from the database as a string.
153 * @var int|string|null
154 * (SQL type: int unsigned)
155 * Note that values will be retrieved from the database as a string.
162 public function __construct() {
163 $this->__table
= 'civicrm_relationship_cache';
164 parent
::__construct();
168 * Returns localized title of this entity.
170 * @param bool $plural
171 * Whether to return the plural version of the title.
173 public static function getEntityTitle($plural = FALSE) {
174 return $plural ?
ts('Related Contacts') : ts('Related Contact');
178 * Returns foreign keys and entity references.
181 * [CRM_Core_Reference_Interface]
183 public static function getReferenceColumns() {
184 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
185 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
186 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
187 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
188 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'near_contact_id', 'civicrm_contact', 'id');
189 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'far_contact_id', 'civicrm_contact', 'id');
190 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_id', 'civicrm_case', 'id');
191 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
193 return Civi
::$statics[__CLASS__
]['links'];
197 * Returns all the column names of this table
201 public static function &fields() {
202 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
203 Civi
::$statics[__CLASS__
]['fields'] = [
206 'type' => CRM_Utils_Type
::T_INT
,
207 'title' => ts('Relationship Cache ID'),
208 'description' => ts('Relationship Cache ID'),
210 'where' => 'civicrm_relationship_cache.id',
211 'table_name' => 'civicrm_relationship_cache',
212 'entity' => 'RelationshipCache',
213 'bao' => 'CRM_Contact_BAO_RelationshipCache',
221 'relationship_id' => [
222 'name' => 'relationship_id',
223 'type' => CRM_Utils_Type
::T_INT
,
224 'title' => ts('Relationship ID'),
225 'description' => ts('id of the relationship (FK to civicrm_relationship.id)'),
227 'where' => 'civicrm_relationship_cache.relationship_id',
228 'table_name' => 'civicrm_relationship_cache',
229 'entity' => 'RelationshipCache',
230 'bao' => 'CRM_Contact_BAO_RelationshipCache',
232 'FKClassName' => 'CRM_Contact_DAO_Relationship',
234 'label' => ts("Relationship"),
239 'relationship_type_id' => [
240 'name' => 'relationship_type_id',
241 'type' => CRM_Utils_Type
::T_INT
,
242 'title' => ts('Relationship Type ID'),
243 'description' => ts('id of the relationship type'),
245 'where' => 'civicrm_relationship_cache.relationship_type_id',
246 'table_name' => 'civicrm_relationship_cache',
247 'entity' => 'RelationshipCache',
248 'bao' => 'CRM_Contact_BAO_RelationshipCache',
250 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
252 'label' => ts("Relationship Type"),
258 'name' => 'orientation',
259 'type' => CRM_Utils_Type
::T_STRING
,
260 'title' => ts('Orientation (a_b or b_a)'),
261 '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.'),
264 'size' => CRM_Utils_Type
::FOUR
,
265 'where' => 'civicrm_relationship_cache.orientation',
266 'table_name' => 'civicrm_relationship_cache',
267 'entity' => 'RelationshipCache',
268 'bao' => 'CRM_Contact_BAO_RelationshipCache',
270 'pseudoconstant' => [
271 'callback' => 'CRM_Core_SelectValues::relationshipOrientation',
276 'near_contact_id' => [
277 'name' => 'near_contact_id',
278 'type' => CRM_Utils_Type
::T_INT
,
279 'title' => ts('Contact ID (Near side)'),
280 'description' => ts('id of the first contact'),
282 'where' => 'civicrm_relationship_cache.near_contact_id',
283 'table_name' => 'civicrm_relationship_cache',
284 'entity' => 'RelationshipCache',
285 'bao' => 'CRM_Contact_BAO_RelationshipCache',
287 'FKClassName' => 'CRM_Contact_DAO_Contact',
289 'type' => 'EntityRef',
290 'label' => ts("Contact (Near side)"),
296 'name' => 'near_relation',
297 'type' => CRM_Utils_Type
::T_STRING
,
298 'title' => ts('Relationship Name (to related contact)'),
299 'description' => ts('name for relationship of near_contact to far_contact.'),
301 'size' => CRM_Utils_Type
::BIG
,
302 'where' => 'civicrm_relationship_cache.near_relation',
303 'table_name' => 'civicrm_relationship_cache',
304 'entity' => 'RelationshipCache',
305 'bao' => 'CRM_Contact_BAO_RelationshipCache',
308 'label' => ts("Relationship to contact"),
310 'pseudoconstant' => [
311 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
316 'far_contact_id' => [
317 'name' => 'far_contact_id',
318 'type' => CRM_Utils_Type
::T_INT
,
319 'title' => ts('Contact ID (Far side)'),
320 'description' => ts('id of the second contact'),
322 'where' => 'civicrm_relationship_cache.far_contact_id',
323 'table_name' => 'civicrm_relationship_cache',
324 'entity' => 'RelationshipCache',
325 'bao' => 'CRM_Contact_BAO_RelationshipCache',
327 'FKClassName' => 'CRM_Contact_DAO_Contact',
329 'type' => 'EntityRef',
330 'label' => ts("Contact (Far side)"),
336 'name' => 'far_relation',
337 'type' => CRM_Utils_Type
::T_STRING
,
338 'title' => ts('Relationship Name (from related contact)'),
339 'description' => ts('name for relationship of far_contact to near_contact.'),
341 'size' => CRM_Utils_Type
::BIG
,
342 'where' => 'civicrm_relationship_cache.far_relation',
343 'table_name' => 'civicrm_relationship_cache',
344 'entity' => 'RelationshipCache',
345 'bao' => 'CRM_Contact_BAO_RelationshipCache',
348 'label' => ts("Relationship from contact"),
350 'pseudoconstant' => [
351 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
357 'name' => 'is_active',
358 'type' => CRM_Utils_Type
::T_BOOLEAN
,
359 'title' => ts('Relationship Is Active'),
360 'description' => ts('is the relationship active ?'),
362 'where' => 'civicrm_relationship_cache.is_active',
364 'table_name' => 'civicrm_relationship_cache',
365 'entity' => 'RelationshipCache',
366 'bao' => 'CRM_Contact_BAO_RelationshipCache',
369 'type' => 'CheckBox',
374 'relationship_start_date' => [
375 'name' => 'start_date',
376 'type' => CRM_Utils_Type
::T_DATE
,
377 'title' => ts('Relationship Start Date'),
378 'description' => ts('date when the relationship started'),
379 'where' => 'civicrm_relationship_cache.start_date',
380 'table_name' => 'civicrm_relationship_cache',
381 'entity' => 'RelationshipCache',
382 'bao' => 'CRM_Contact_BAO_RelationshipCache',
385 'type' => 'Select Date',
386 'formatType' => 'activityDate',
391 'relationship_end_date' => [
392 'name' => 'end_date',
393 'type' => CRM_Utils_Type
::T_DATE
,
394 'title' => ts('Relationship End Date'),
395 'description' => ts('date when the relationship ended'),
396 'where' => 'civicrm_relationship_cache.end_date',
397 'table_name' => 'civicrm_relationship_cache',
398 'entity' => 'RelationshipCache',
399 'bao' => 'CRM_Contact_BAO_RelationshipCache',
402 'type' => 'Select Date',
403 'formatType' => 'activityDate',
410 'type' => CRM_Utils_Type
::T_INT
,
411 'title' => ts('Case ID'),
412 'description' => ts('FK to civicrm_case'),
413 'where' => 'civicrm_relationship_cache.case_id',
415 'table_name' => 'civicrm_relationship_cache',
416 'entity' => 'RelationshipCache',
417 'bao' => 'CRM_Contact_BAO_RelationshipCache',
419 'FKClassName' => 'CRM_Case_DAO_Case',
420 'component' => 'CiviCase',
422 'label' => ts("Case"),
428 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
430 return Civi
::$statics[__CLASS__
]['fields'];
434 * Return a mapping from field-name to the corresponding key (as used in fields()).
437 * Array(string $name => string $uniqueName).
439 public static function &fieldKeys() {
440 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
441 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
443 return Civi
::$statics[__CLASS__
]['fieldKeys'];
447 * Returns the names of this table
451 public static function getTableName() {
452 return self
::$_tableName;
456 * Returns if this table needs to be logged
460 public function getLog() {
465 * Returns the list of fields that can be imported
467 * @param bool $prefix
471 public static function &import($prefix = FALSE) {
472 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship_cache', $prefix, []);
477 * Returns the list of fields that can be exported
479 * @param bool $prefix
483 public static function &export($prefix = FALSE) {
484 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship_cache', $prefix, []);
489 * Returns the list of indices
491 * @param bool $localize
495 public static function indices($localize = TRUE) {
497 'UI_relationship' => [
498 'name' => 'UI_relationship',
500 0 => 'relationship_id',
503 'localizable' => FALSE,
505 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation',
507 'index_nearid_nearrelation' => [
508 'name' => 'index_nearid_nearrelation',
510 0 => 'near_contact_id',
511 1 => 'near_relation',
513 'localizable' => FALSE,
514 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation',
516 'index_nearid_farrelation' => [
517 'name' => 'index_nearid_farrelation',
519 0 => 'near_contact_id',
522 'localizable' => FALSE,
523 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation',
525 'index_near_relation' => [
526 'name' => 'index_near_relation',
528 0 => 'near_relation',
530 'localizable' => FALSE,
531 'sig' => 'civicrm_relationship_cache::0::near_relation',
534 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;