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:d511533f30d5d2d8deac82664a6288d1)
13 * Database access object for the RelationshipCache entity.
15 class CRM_Contact_DAO_RelationshipCache
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_relationship_cache';
25 * Icon associated with this entity.
29 public static $_icon = 'fa-handshake-o';
32 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 public static $_log = FALSE;
39 * Relationship Cache ID
46 * id of the relationship (FK to civicrm_relationship.id)
50 public $relationship_id;
53 * id of the relationship type
57 public $relationship_type_id;
60 * 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.
67 * id of the first contact
71 public $near_contact_id;
74 * name for relationship of near_contact to far_contact.
78 public $near_relation;
81 * id of the second contact
85 public $far_contact_id;
88 * name for relationship of far_contact to near_contact.
95 * is the relationship active ?
102 * date when the relationship started
109 * date when the relationship ended
118 public function __construct() {
119 $this->__table
= 'civicrm_relationship_cache';
120 parent
::__construct();
124 * Returns localized title of this entity.
126 public static function getEntityTitle() {
127 return ts('Relationship Caches');
131 * Returns foreign keys and entity references.
134 * [CRM_Core_Reference_Interface]
136 public static function getReferenceColumns() {
137 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
138 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
139 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
140 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
141 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'near_contact_id', 'civicrm_contact', 'id');
142 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'far_contact_id', 'civicrm_contact', 'id');
143 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
145 return Civi
::$statics[__CLASS__
]['links'];
149 * Returns all the column names of this table
153 public static function &fields() {
154 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
155 Civi
::$statics[__CLASS__
]['fields'] = [
158 'type' => CRM_Utils_Type
::T_INT
,
159 'title' => ts('Relationship Cache ID'),
160 'description' => ts('Relationship Cache ID'),
162 'where' => 'civicrm_relationship_cache.id',
163 'table_name' => 'civicrm_relationship_cache',
164 'entity' => 'RelationshipCache',
165 'bao' => 'CRM_Contact_BAO_RelationshipCache',
169 'relationship_id' => [
170 'name' => 'relationship_id',
171 'type' => CRM_Utils_Type
::T_INT
,
172 'title' => ts('Relationship'),
173 'description' => ts('id of the relationship (FK to civicrm_relationship.id)'),
175 'where' => 'civicrm_relationship_cache.relationship_id',
176 'table_name' => 'civicrm_relationship_cache',
177 'entity' => 'RelationshipCache',
178 'bao' => 'CRM_Contact_BAO_RelationshipCache',
180 'FKClassName' => 'CRM_Contact_DAO_Relationship',
183 'relationship_type_id' => [
184 'name' => 'relationship_type_id',
185 'type' => CRM_Utils_Type
::T_INT
,
186 'title' => ts('Relationship Type'),
187 'description' => ts('id of the relationship type'),
189 'where' => 'civicrm_relationship_cache.relationship_type_id',
190 'table_name' => 'civicrm_relationship_cache',
191 'entity' => 'RelationshipCache',
192 'bao' => 'CRM_Contact_BAO_RelationshipCache',
194 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
198 'name' => 'orientation',
199 'type' => CRM_Utils_Type
::T_STRING
,
200 'title' => ts('Orientation (a_b or b_a)'),
201 '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.'),
204 'size' => CRM_Utils_Type
::FOUR
,
205 'where' => 'civicrm_relationship_cache.orientation',
206 'table_name' => 'civicrm_relationship_cache',
207 'entity' => 'RelationshipCache',
208 'bao' => 'CRM_Contact_BAO_RelationshipCache',
210 'pseudoconstant' => [
211 'callback' => 'CRM_Core_SelectValues::relationshipOrientation',
215 'near_contact_id' => [
216 'name' => 'near_contact_id',
217 'type' => CRM_Utils_Type
::T_INT
,
218 'title' => ts('Contact ID (Near side)'),
219 'description' => ts('id of the first contact'),
221 'where' => 'civicrm_relationship_cache.near_contact_id',
222 'table_name' => 'civicrm_relationship_cache',
223 'entity' => 'RelationshipCache',
224 'bao' => 'CRM_Contact_BAO_RelationshipCache',
226 'FKClassName' => 'CRM_Contact_DAO_Contact',
228 'type' => 'EntityRef',
233 'name' => 'near_relation',
234 'type' => CRM_Utils_Type
::T_STRING
,
235 'title' => ts('Relationship Name (Near side)'),
236 'description' => ts('name for relationship of near_contact to far_contact.'),
238 'size' => CRM_Utils_Type
::BIG
,
239 'where' => 'civicrm_relationship_cache.near_relation',
240 'table_name' => 'civicrm_relationship_cache',
241 'entity' => 'RelationshipCache',
242 'bao' => 'CRM_Contact_BAO_RelationshipCache',
244 'pseudoconstant' => [
245 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
249 'far_contact_id' => [
250 'name' => 'far_contact_id',
251 'type' => CRM_Utils_Type
::T_INT
,
252 'title' => ts('Contact ID (Far side)'),
253 'description' => ts('id of the second contact'),
255 'where' => 'civicrm_relationship_cache.far_contact_id',
256 'table_name' => 'civicrm_relationship_cache',
257 'entity' => 'RelationshipCache',
258 'bao' => 'CRM_Contact_BAO_RelationshipCache',
260 'FKClassName' => 'CRM_Contact_DAO_Contact',
262 'type' => 'EntityRef',
267 'name' => 'far_relation',
268 'type' => CRM_Utils_Type
::T_STRING
,
269 'title' => ts('Relationship Name (Near side)'),
270 'description' => ts('name for relationship of far_contact to near_contact.'),
272 'size' => CRM_Utils_Type
::BIG
,
273 'where' => 'civicrm_relationship_cache.far_relation',
274 'table_name' => 'civicrm_relationship_cache',
275 'entity' => 'RelationshipCache',
276 'bao' => 'CRM_Contact_BAO_RelationshipCache',
278 'pseudoconstant' => [
279 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
284 'name' => 'is_active',
285 'type' => CRM_Utils_Type
::T_BOOLEAN
,
286 'title' => ts('Relationship Is Active'),
287 'description' => ts('is the relationship active ?'),
288 'where' => 'civicrm_relationship_cache.is_active',
290 'table_name' => 'civicrm_relationship_cache',
291 'entity' => 'RelationshipCache',
292 'bao' => 'CRM_Contact_BAO_RelationshipCache',
295 'type' => 'CheckBox',
299 'relationship_start_date' => [
300 'name' => 'start_date',
301 'type' => CRM_Utils_Type
::T_DATE
,
302 'title' => ts('Relationship Start Date'),
303 'description' => ts('date when the relationship started'),
304 'where' => 'civicrm_relationship_cache.start_date',
305 'table_name' => 'civicrm_relationship_cache',
306 'entity' => 'RelationshipCache',
307 'bao' => 'CRM_Contact_BAO_RelationshipCache',
310 'type' => 'Select Date',
311 'formatType' => 'activityDate',
315 'relationship_end_date' => [
316 'name' => 'end_date',
317 'type' => CRM_Utils_Type
::T_DATE
,
318 'title' => ts('Relationship End Date'),
319 'description' => ts('date when the relationship ended'),
320 'where' => 'civicrm_relationship_cache.end_date',
321 'table_name' => 'civicrm_relationship_cache',
322 'entity' => 'RelationshipCache',
323 'bao' => 'CRM_Contact_BAO_RelationshipCache',
326 'type' => 'Select Date',
327 'formatType' => 'activityDate',
332 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
334 return Civi
::$statics[__CLASS__
]['fields'];
338 * Return a mapping from field-name to the corresponding key (as used in fields()).
341 * Array(string $name => string $uniqueName).
343 public static function &fieldKeys() {
344 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
345 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
347 return Civi
::$statics[__CLASS__
]['fieldKeys'];
351 * Returns the names of this table
355 public static function getTableName() {
356 return self
::$_tableName;
360 * Returns if this table needs to be logged
364 public function getLog() {
369 * Returns the list of fields that can be imported
371 * @param bool $prefix
375 public static function &import($prefix = FALSE) {
376 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship_cache', $prefix, []);
381 * Returns the list of fields that can be exported
383 * @param bool $prefix
387 public static function &export($prefix = FALSE) {
388 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship_cache', $prefix, []);
393 * Returns the list of indices
395 * @param bool $localize
399 public static function indices($localize = TRUE) {
401 'UI_relationship' => [
402 'name' => 'UI_relationship',
404 0 => 'relationship_id',
407 'localizable' => FALSE,
409 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation',
411 'index_nearid_nearrelation' => [
412 'name' => 'index_nearid_nearrelation',
414 0 => 'near_contact_id',
415 1 => 'near_relation',
417 'localizable' => FALSE,
418 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation',
420 'index_nearid_farrelation' => [
421 'name' => 'index_nearid_farrelation',
423 0 => 'near_contact_id',
426 'localizable' => FALSE,
427 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation',
429 'index_near_relation' => [
430 'name' => 'index_near_relation',
432 0 => 'near_relation',
434 'localizable' => FALSE,
435 'sig' => 'civicrm_relationship_cache::0::near_relation',
438 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;