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:b35c483041c2cf38afed94446977fa1e)
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',
174 'relationship_id' => [
175 'name' => 'relationship_id',
176 'type' => CRM_Utils_Type
::T_INT
,
177 'title' => ts('Relationship'),
178 'description' => ts('id of the relationship (FK to civicrm_relationship.id)'),
180 'where' => 'civicrm_relationship_cache.relationship_id',
181 'table_name' => 'civicrm_relationship_cache',
182 'entity' => 'RelationshipCache',
183 'bao' => 'CRM_Contact_BAO_RelationshipCache',
185 'FKClassName' => 'CRM_Contact_DAO_Relationship',
188 'relationship_type_id' => [
189 'name' => 'relationship_type_id',
190 'type' => CRM_Utils_Type
::T_INT
,
191 'title' => ts('Relationship Type'),
192 'description' => ts('id of the relationship type'),
194 'where' => 'civicrm_relationship_cache.relationship_type_id',
195 'table_name' => 'civicrm_relationship_cache',
196 'entity' => 'RelationshipCache',
197 'bao' => 'CRM_Contact_BAO_RelationshipCache',
199 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
203 'name' => 'orientation',
204 'type' => CRM_Utils_Type
::T_STRING
,
205 'title' => ts('Orientation (a_b or b_a)'),
206 '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.'),
209 'size' => CRM_Utils_Type
::FOUR
,
210 'where' => 'civicrm_relationship_cache.orientation',
211 'table_name' => 'civicrm_relationship_cache',
212 'entity' => 'RelationshipCache',
213 'bao' => 'CRM_Contact_BAO_RelationshipCache',
215 'pseudoconstant' => [
216 'callback' => 'CRM_Core_SelectValues::relationshipOrientation',
220 'near_contact_id' => [
221 'name' => 'near_contact_id',
222 'type' => CRM_Utils_Type
::T_INT
,
223 'title' => ts('Contact ID (Near side)'),
224 'description' => ts('id of the first contact'),
226 'where' => 'civicrm_relationship_cache.near_contact_id',
227 'table_name' => 'civicrm_relationship_cache',
228 'entity' => 'RelationshipCache',
229 'bao' => 'CRM_Contact_BAO_RelationshipCache',
231 'FKClassName' => 'CRM_Contact_DAO_Contact',
233 'type' => 'EntityRef',
238 'name' => 'near_relation',
239 'type' => CRM_Utils_Type
::T_STRING
,
240 'title' => ts('Relationship Name (to related contact)'),
241 'description' => ts('name for relationship of near_contact to far_contact.'),
243 'size' => CRM_Utils_Type
::BIG
,
244 'where' => 'civicrm_relationship_cache.near_relation',
245 'table_name' => 'civicrm_relationship_cache',
246 'entity' => 'RelationshipCache',
247 'bao' => 'CRM_Contact_BAO_RelationshipCache',
250 'label' => ts("Relationship to contact"),
252 'pseudoconstant' => [
253 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
257 'far_contact_id' => [
258 'name' => 'far_contact_id',
259 'type' => CRM_Utils_Type
::T_INT
,
260 'title' => ts('Contact ID (Far side)'),
261 'description' => ts('id of the second contact'),
263 'where' => 'civicrm_relationship_cache.far_contact_id',
264 'table_name' => 'civicrm_relationship_cache',
265 'entity' => 'RelationshipCache',
266 'bao' => 'CRM_Contact_BAO_RelationshipCache',
268 'FKClassName' => 'CRM_Contact_DAO_Contact',
270 'type' => 'EntityRef',
275 'name' => 'far_relation',
276 'type' => CRM_Utils_Type
::T_STRING
,
277 'title' => ts('Relationship Name (from related contact)'),
278 'description' => ts('name for relationship of far_contact to near_contact.'),
280 'size' => CRM_Utils_Type
::BIG
,
281 'where' => 'civicrm_relationship_cache.far_relation',
282 'table_name' => 'civicrm_relationship_cache',
283 'entity' => 'RelationshipCache',
284 'bao' => 'CRM_Contact_BAO_RelationshipCache',
287 'label' => ts("Relationship from contact"),
289 'pseudoconstant' => [
290 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
295 'name' => 'is_active',
296 'type' => CRM_Utils_Type
::T_BOOLEAN
,
297 'title' => ts('Relationship Is Active'),
298 'description' => ts('is the relationship active ?'),
299 'where' => 'civicrm_relationship_cache.is_active',
301 'table_name' => 'civicrm_relationship_cache',
302 'entity' => 'RelationshipCache',
303 'bao' => 'CRM_Contact_BAO_RelationshipCache',
306 'type' => 'CheckBox',
310 'relationship_start_date' => [
311 'name' => 'start_date',
312 'type' => CRM_Utils_Type
::T_DATE
,
313 'title' => ts('Relationship Start Date'),
314 'description' => ts('date when the relationship started'),
315 'where' => 'civicrm_relationship_cache.start_date',
316 'table_name' => 'civicrm_relationship_cache',
317 'entity' => 'RelationshipCache',
318 'bao' => 'CRM_Contact_BAO_RelationshipCache',
321 'type' => 'Select Date',
322 'formatType' => 'activityDate',
326 'relationship_end_date' => [
327 'name' => 'end_date',
328 'type' => CRM_Utils_Type
::T_DATE
,
329 'title' => ts('Relationship End Date'),
330 'description' => ts('date when the relationship ended'),
331 'where' => 'civicrm_relationship_cache.end_date',
332 'table_name' => 'civicrm_relationship_cache',
333 'entity' => 'RelationshipCache',
334 'bao' => 'CRM_Contact_BAO_RelationshipCache',
337 'type' => 'Select Date',
338 'formatType' => 'activityDate',
343 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
345 return Civi
::$statics[__CLASS__
]['fields'];
349 * Return a mapping from field-name to the corresponding key (as used in fields()).
352 * Array(string $name => string $uniqueName).
354 public static function &fieldKeys() {
355 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
356 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
358 return Civi
::$statics[__CLASS__
]['fieldKeys'];
362 * Returns the names of this table
366 public static function getTableName() {
367 return self
::$_tableName;
371 * Returns if this table needs to be logged
375 public function getLog() {
380 * Returns the list of fields that can be imported
382 * @param bool $prefix
386 public static function &import($prefix = FALSE) {
387 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship_cache', $prefix, []);
392 * Returns the list of fields that can be exported
394 * @param bool $prefix
398 public static function &export($prefix = FALSE) {
399 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship_cache', $prefix, []);
404 * Returns the list of indices
406 * @param bool $localize
410 public static function indices($localize = TRUE) {
412 'UI_relationship' => [
413 'name' => 'UI_relationship',
415 0 => 'relationship_id',
418 'localizable' => FALSE,
420 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation',
422 'index_nearid_nearrelation' => [
423 'name' => 'index_nearid_nearrelation',
425 0 => 'near_contact_id',
426 1 => 'near_relation',
428 'localizable' => FALSE,
429 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation',
431 'index_nearid_farrelation' => [
432 'name' => 'index_nearid_farrelation',
434 0 => 'near_contact_id',
437 'localizable' => FALSE,
438 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation',
440 'index_near_relation' => [
441 'name' => 'index_near_relation',
443 0 => 'near_relation',
445 'localizable' => FALSE,
446 'sig' => 'civicrm_relationship_cache::0::near_relation',
449 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;