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:6a586a5a5550a64db4c9907387c1411d)
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',
212 'near_contact_id' => [
213 'name' => 'near_contact_id',
214 'type' => CRM_Utils_Type
::T_INT
,
215 'title' => ts('Contact ID (Near side)'),
216 'description' => ts('id of the first contact'),
218 'where' => 'civicrm_relationship_cache.near_contact_id',
219 'table_name' => 'civicrm_relationship_cache',
220 'entity' => 'RelationshipCache',
221 'bao' => 'CRM_Contact_BAO_RelationshipCache',
223 'FKClassName' => 'CRM_Contact_DAO_Contact',
227 'name' => 'near_relation',
228 'type' => CRM_Utils_Type
::T_STRING
,
229 'title' => ts('Relationship Name (Near side)'),
230 'description' => ts('name for relationship of near_contact to far_contact.'),
232 'size' => CRM_Utils_Type
::BIG
,
233 'where' => 'civicrm_relationship_cache.near_relation',
234 'table_name' => 'civicrm_relationship_cache',
235 'entity' => 'RelationshipCache',
236 'bao' => 'CRM_Contact_BAO_RelationshipCache',
240 'far_contact_id' => [
241 'name' => 'far_contact_id',
242 'type' => CRM_Utils_Type
::T_INT
,
243 'title' => ts('Contact ID (Far side)'),
244 'description' => ts('id of the second contact'),
246 'where' => 'civicrm_relationship_cache.far_contact_id',
247 'table_name' => 'civicrm_relationship_cache',
248 'entity' => 'RelationshipCache',
249 'bao' => 'CRM_Contact_BAO_RelationshipCache',
251 'FKClassName' => 'CRM_Contact_DAO_Contact',
253 'type' => 'EntityRef',
258 'name' => 'far_relation',
259 'type' => CRM_Utils_Type
::T_STRING
,
260 'title' => ts('Relationship Name (Near side)'),
261 'description' => ts('name for relationship of far_contact to near_contact.'),
263 'size' => CRM_Utils_Type
::BIG
,
264 'where' => 'civicrm_relationship_cache.far_relation',
265 'table_name' => 'civicrm_relationship_cache',
266 'entity' => 'RelationshipCache',
267 'bao' => 'CRM_Contact_BAO_RelationshipCache',
272 'name' => 'is_active',
273 'type' => CRM_Utils_Type
::T_BOOLEAN
,
274 'title' => ts('Relationship Is Active'),
275 'description' => ts('is the relationship active ?'),
276 'where' => 'civicrm_relationship_cache.is_active',
278 'table_name' => 'civicrm_relationship_cache',
279 'entity' => 'RelationshipCache',
280 'bao' => 'CRM_Contact_BAO_RelationshipCache',
283 'type' => 'CheckBox',
287 'relationship_start_date' => [
288 'name' => 'start_date',
289 'type' => CRM_Utils_Type
::T_DATE
,
290 'title' => ts('Relationship Start Date'),
291 'description' => ts('date when the relationship started'),
292 'where' => 'civicrm_relationship_cache.start_date',
293 'table_name' => 'civicrm_relationship_cache',
294 'entity' => 'RelationshipCache',
295 'bao' => 'CRM_Contact_BAO_RelationshipCache',
298 'type' => 'Select Date',
299 'formatType' => 'activityDate',
303 'relationship_end_date' => [
304 'name' => 'end_date',
305 'type' => CRM_Utils_Type
::T_DATE
,
306 'title' => ts('Relationship End Date'),
307 'description' => ts('date when the relationship ended'),
308 'where' => 'civicrm_relationship_cache.end_date',
309 'table_name' => 'civicrm_relationship_cache',
310 'entity' => 'RelationshipCache',
311 'bao' => 'CRM_Contact_BAO_RelationshipCache',
314 'type' => 'Select Date',
315 'formatType' => 'activityDate',
320 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
322 return Civi
::$statics[__CLASS__
]['fields'];
326 * Return a mapping from field-name to the corresponding key (as used in fields()).
329 * Array(string $name => string $uniqueName).
331 public static function &fieldKeys() {
332 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
333 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
335 return Civi
::$statics[__CLASS__
]['fieldKeys'];
339 * Returns the names of this table
343 public static function getTableName() {
344 return self
::$_tableName;
348 * Returns if this table needs to be logged
352 public function getLog() {
357 * Returns the list of fields that can be imported
359 * @param bool $prefix
363 public static function &import($prefix = FALSE) {
364 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship_cache', $prefix, []);
369 * Returns the list of fields that can be exported
371 * @param bool $prefix
375 public static function &export($prefix = FALSE) {
376 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship_cache', $prefix, []);
381 * Returns the list of indices
383 * @param bool $localize
387 public static function indices($localize = TRUE) {
389 'UI_relationship' => [
390 'name' => 'UI_relationship',
392 0 => 'relationship_id',
395 'localizable' => FALSE,
397 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation',
399 'index_nearid_nearrelation' => [
400 'name' => 'index_nearid_nearrelation',
402 0 => 'near_contact_id',
403 1 => 'near_relation',
405 'localizable' => FALSE,
406 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation',
408 'index_nearid_farrelation' => [
409 'name' => 'index_nearid_farrelation',
411 0 => 'near_contact_id',
414 'localizable' => FALSE,
415 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation',
417 'index_near_relation' => [
418 'name' => 'index_near_relation',
420 0 => 'near_relation',
422 'localizable' => FALSE,
423 'sig' => 'civicrm_relationship_cache::0::near_relation',
426 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;