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:3376402e2a249b7004b40df6aeac5df9)
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 * Relationship Cache ID
48 * id of the relationship (FK to civicrm_relationship.id)
52 public $relationship_id;
55 * id of the relationship type
59 public $relationship_type_id;
62 * 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.
69 * id of the first contact
73 public $near_contact_id;
76 * name for relationship of near_contact to far_contact.
80 public $near_relation;
83 * id of the second contact
87 public $far_contact_id;
90 * name for relationship of far_contact to near_contact.
97 * is the relationship active ?
104 * date when the relationship started
111 * date when the relationship ended
120 public function __construct() {
121 $this->__table
= 'civicrm_relationship_cache';
122 parent
::__construct();
126 * Returns localized title of this entity.
128 * @param bool $plural
129 * Whether to return the plural version of the title.
131 public static function getEntityTitle($plural = FALSE) {
132 return $plural ?
ts('Related Contacts') : ts('Related Contact');
136 * Returns foreign keys and entity references.
139 * [CRM_Core_Reference_Interface]
141 public static function getReferenceColumns() {
142 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
143 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
144 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
145 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
146 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'near_contact_id', 'civicrm_contact', 'id');
147 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'far_contact_id', 'civicrm_contact', 'id');
148 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
150 return Civi
::$statics[__CLASS__
]['links'];
154 * Returns all the column names of this table
158 public static function &fields() {
159 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
160 Civi
::$statics[__CLASS__
]['fields'] = [
163 'type' => CRM_Utils_Type
::T_INT
,
164 'title' => ts('Relationship Cache ID'),
165 'description' => ts('Relationship Cache ID'),
167 'where' => 'civicrm_relationship_cache.id',
168 'table_name' => 'civicrm_relationship_cache',
169 'entity' => 'RelationshipCache',
170 'bao' => 'CRM_Contact_BAO_RelationshipCache',
178 'relationship_id' => [
179 'name' => 'relationship_id',
180 'type' => CRM_Utils_Type
::T_INT
,
181 'title' => ts('Relationship ID'),
182 'description' => ts('id of the relationship (FK to civicrm_relationship.id)'),
184 'where' => 'civicrm_relationship_cache.relationship_id',
185 'table_name' => 'civicrm_relationship_cache',
186 'entity' => 'RelationshipCache',
187 'bao' => 'CRM_Contact_BAO_RelationshipCache',
189 'FKClassName' => 'CRM_Contact_DAO_Relationship',
191 'label' => ts("Relationship"),
196 'relationship_type_id' => [
197 'name' => 'relationship_type_id',
198 'type' => CRM_Utils_Type
::T_INT
,
199 'title' => ts('Relationship Type ID'),
200 'description' => ts('id of the relationship type'),
202 'where' => 'civicrm_relationship_cache.relationship_type_id',
203 'table_name' => 'civicrm_relationship_cache',
204 'entity' => 'RelationshipCache',
205 'bao' => 'CRM_Contact_BAO_RelationshipCache',
207 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
209 'label' => ts("Relationship Type"),
215 'name' => 'orientation',
216 'type' => CRM_Utils_Type
::T_STRING
,
217 'title' => ts('Orientation (a_b or b_a)'),
218 '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.'),
221 'size' => CRM_Utils_Type
::FOUR
,
222 'where' => 'civicrm_relationship_cache.orientation',
223 'table_name' => 'civicrm_relationship_cache',
224 'entity' => 'RelationshipCache',
225 'bao' => 'CRM_Contact_BAO_RelationshipCache',
227 'pseudoconstant' => [
228 'callback' => 'CRM_Core_SelectValues::relationshipOrientation',
233 'near_contact_id' => [
234 'name' => 'near_contact_id',
235 'type' => CRM_Utils_Type
::T_INT
,
236 'title' => ts('Contact ID (Near side)'),
237 'description' => ts('id of the first contact'),
239 'where' => 'civicrm_relationship_cache.near_contact_id',
240 'table_name' => 'civicrm_relationship_cache',
241 'entity' => 'RelationshipCache',
242 'bao' => 'CRM_Contact_BAO_RelationshipCache',
244 'FKClassName' => 'CRM_Contact_DAO_Contact',
246 'type' => 'EntityRef',
247 'label' => ts("Contact (Near side)"),
253 'name' => 'near_relation',
254 'type' => CRM_Utils_Type
::T_STRING
,
255 'title' => ts('Relationship Name (to related contact)'),
256 'description' => ts('name for relationship of near_contact to far_contact.'),
258 'size' => CRM_Utils_Type
::BIG
,
259 'where' => 'civicrm_relationship_cache.near_relation',
260 'table_name' => 'civicrm_relationship_cache',
261 'entity' => 'RelationshipCache',
262 'bao' => 'CRM_Contact_BAO_RelationshipCache',
265 'label' => ts("Relationship to contact"),
267 'pseudoconstant' => [
268 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
273 'far_contact_id' => [
274 'name' => 'far_contact_id',
275 'type' => CRM_Utils_Type
::T_INT
,
276 'title' => ts('Contact ID (Far side)'),
277 'description' => ts('id of the second contact'),
279 'where' => 'civicrm_relationship_cache.far_contact_id',
280 'table_name' => 'civicrm_relationship_cache',
281 'entity' => 'RelationshipCache',
282 'bao' => 'CRM_Contact_BAO_RelationshipCache',
284 'FKClassName' => 'CRM_Contact_DAO_Contact',
286 'type' => 'EntityRef',
287 'label' => ts("Contact (Far side)"),
293 'name' => 'far_relation',
294 'type' => CRM_Utils_Type
::T_STRING
,
295 'title' => ts('Relationship Name (from related contact)'),
296 'description' => ts('name for relationship of far_contact to near_contact.'),
298 'size' => CRM_Utils_Type
::BIG
,
299 'where' => 'civicrm_relationship_cache.far_relation',
300 'table_name' => 'civicrm_relationship_cache',
301 'entity' => 'RelationshipCache',
302 'bao' => 'CRM_Contact_BAO_RelationshipCache',
305 'label' => ts("Relationship from contact"),
307 'pseudoconstant' => [
308 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
314 'name' => 'is_active',
315 'type' => CRM_Utils_Type
::T_BOOLEAN
,
316 'title' => ts('Relationship Is Active'),
317 'description' => ts('is the relationship active ?'),
318 'where' => 'civicrm_relationship_cache.is_active',
320 'table_name' => 'civicrm_relationship_cache',
321 'entity' => 'RelationshipCache',
322 'bao' => 'CRM_Contact_BAO_RelationshipCache',
325 'type' => 'CheckBox',
330 'relationship_start_date' => [
331 'name' => 'start_date',
332 'type' => CRM_Utils_Type
::T_DATE
,
333 'title' => ts('Relationship Start Date'),
334 'description' => ts('date when the relationship started'),
335 'where' => 'civicrm_relationship_cache.start_date',
336 'table_name' => 'civicrm_relationship_cache',
337 'entity' => 'RelationshipCache',
338 'bao' => 'CRM_Contact_BAO_RelationshipCache',
341 'type' => 'Select Date',
342 'formatType' => 'activityDate',
347 'relationship_end_date' => [
348 'name' => 'end_date',
349 'type' => CRM_Utils_Type
::T_DATE
,
350 'title' => ts('Relationship End Date'),
351 'description' => ts('date when the relationship ended'),
352 'where' => 'civicrm_relationship_cache.end_date',
353 'table_name' => 'civicrm_relationship_cache',
354 'entity' => 'RelationshipCache',
355 'bao' => 'CRM_Contact_BAO_RelationshipCache',
358 'type' => 'Select Date',
359 'formatType' => 'activityDate',
365 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
367 return Civi
::$statics[__CLASS__
]['fields'];
371 * Return a mapping from field-name to the corresponding key (as used in fields()).
374 * Array(string $name => string $uniqueName).
376 public static function &fieldKeys() {
377 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
378 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
380 return Civi
::$statics[__CLASS__
]['fieldKeys'];
384 * Returns the names of this table
388 public static function getTableName() {
389 return self
::$_tableName;
393 * Returns if this table needs to be logged
397 public function getLog() {
402 * Returns the list of fields that can be imported
404 * @param bool $prefix
408 public static function &import($prefix = FALSE) {
409 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship_cache', $prefix, []);
414 * Returns the list of fields that can be exported
416 * @param bool $prefix
420 public static function &export($prefix = FALSE) {
421 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship_cache', $prefix, []);
426 * Returns the list of indices
428 * @param bool $localize
432 public static function indices($localize = TRUE) {
434 'UI_relationship' => [
435 'name' => 'UI_relationship',
437 0 => 'relationship_id',
440 'localizable' => FALSE,
442 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation',
444 'index_nearid_nearrelation' => [
445 'name' => 'index_nearid_nearrelation',
447 0 => 'near_contact_id',
448 1 => 'near_relation',
450 'localizable' => FALSE,
451 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation',
453 'index_nearid_farrelation' => [
454 'name' => 'index_nearid_farrelation',
456 0 => 'near_contact_id',
459 'localizable' => FALSE,
460 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation',
462 'index_near_relation' => [
463 'name' => 'index_near_relation',
465 0 => 'near_relation',
467 'localizable' => FALSE,
468 'sig' => 'civicrm_relationship_cache::0::near_relation',
471 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;