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:b40781c15c3351a766a6083522f0e5e4)
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 public static function getEntityTitle() {
129 return ts('Relationship Caches');
133 * Returns foreign keys and entity references.
136 * [CRM_Core_Reference_Interface]
138 public static function getReferenceColumns() {
139 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
140 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
141 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
142 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
143 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'near_contact_id', 'civicrm_contact', 'id');
144 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'far_contact_id', 'civicrm_contact', 'id');
145 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
147 return Civi
::$statics[__CLASS__
]['links'];
151 * Returns all the column names of this table
155 public static function &fields() {
156 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
157 Civi
::$statics[__CLASS__
]['fields'] = [
160 'type' => CRM_Utils_Type
::T_INT
,
161 'title' => ts('Relationship Cache ID'),
162 'description' => ts('Relationship Cache ID'),
164 'where' => 'civicrm_relationship_cache.id',
165 'table_name' => 'civicrm_relationship_cache',
166 'entity' => 'RelationshipCache',
167 'bao' => 'CRM_Contact_BAO_RelationshipCache',
171 'relationship_id' => [
172 'name' => 'relationship_id',
173 'type' => CRM_Utils_Type
::T_INT
,
174 'title' => ts('Relationship'),
175 'description' => ts('id of the relationship (FK to civicrm_relationship.id)'),
177 'where' => 'civicrm_relationship_cache.relationship_id',
178 'table_name' => 'civicrm_relationship_cache',
179 'entity' => 'RelationshipCache',
180 'bao' => 'CRM_Contact_BAO_RelationshipCache',
182 'FKClassName' => 'CRM_Contact_DAO_Relationship',
185 'relationship_type_id' => [
186 'name' => 'relationship_type_id',
187 'type' => CRM_Utils_Type
::T_INT
,
188 'title' => ts('Relationship Type'),
189 'description' => ts('id of the relationship type'),
191 'where' => 'civicrm_relationship_cache.relationship_type_id',
192 'table_name' => 'civicrm_relationship_cache',
193 'entity' => 'RelationshipCache',
194 'bao' => 'CRM_Contact_BAO_RelationshipCache',
196 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
200 'name' => 'orientation',
201 'type' => CRM_Utils_Type
::T_STRING
,
202 'title' => ts('Orientation (a_b or b_a)'),
203 '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.'),
206 'size' => CRM_Utils_Type
::FOUR
,
207 'where' => 'civicrm_relationship_cache.orientation',
208 'table_name' => 'civicrm_relationship_cache',
209 'entity' => 'RelationshipCache',
210 'bao' => 'CRM_Contact_BAO_RelationshipCache',
212 'pseudoconstant' => [
213 'callback' => 'CRM_Core_SelectValues::relationshipOrientation',
217 'near_contact_id' => [
218 'name' => 'near_contact_id',
219 'type' => CRM_Utils_Type
::T_INT
,
220 'title' => ts('Contact ID (Near side)'),
221 'description' => ts('id of the first contact'),
223 'where' => 'civicrm_relationship_cache.near_contact_id',
224 'table_name' => 'civicrm_relationship_cache',
225 'entity' => 'RelationshipCache',
226 'bao' => 'CRM_Contact_BAO_RelationshipCache',
228 'FKClassName' => 'CRM_Contact_DAO_Contact',
230 'type' => 'EntityRef',
235 'name' => 'near_relation',
236 'type' => CRM_Utils_Type
::T_STRING
,
237 'title' => ts('Relationship Name (Near side)'),
238 'description' => ts('name for relationship of near_contact to far_contact.'),
240 'size' => CRM_Utils_Type
::BIG
,
241 'where' => 'civicrm_relationship_cache.near_relation',
242 'table_name' => 'civicrm_relationship_cache',
243 'entity' => 'RelationshipCache',
244 'bao' => 'CRM_Contact_BAO_RelationshipCache',
246 'pseudoconstant' => [
247 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
251 'far_contact_id' => [
252 'name' => 'far_contact_id',
253 'type' => CRM_Utils_Type
::T_INT
,
254 'title' => ts('Contact ID (Far side)'),
255 'description' => ts('id of the second contact'),
257 'where' => 'civicrm_relationship_cache.far_contact_id',
258 'table_name' => 'civicrm_relationship_cache',
259 'entity' => 'RelationshipCache',
260 'bao' => 'CRM_Contact_BAO_RelationshipCache',
262 'FKClassName' => 'CRM_Contact_DAO_Contact',
264 'type' => 'EntityRef',
269 'name' => 'far_relation',
270 'type' => CRM_Utils_Type
::T_STRING
,
271 'title' => ts('Relationship Name (Near side)'),
272 'description' => ts('name for relationship of far_contact to near_contact.'),
274 'size' => CRM_Utils_Type
::BIG
,
275 'where' => 'civicrm_relationship_cache.far_relation',
276 'table_name' => 'civicrm_relationship_cache',
277 'entity' => 'RelationshipCache',
278 'bao' => 'CRM_Contact_BAO_RelationshipCache',
280 'pseudoconstant' => [
281 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
286 'name' => 'is_active',
287 'type' => CRM_Utils_Type
::T_BOOLEAN
,
288 'title' => ts('Relationship Is Active'),
289 'description' => ts('is the relationship active ?'),
290 'where' => 'civicrm_relationship_cache.is_active',
292 'table_name' => 'civicrm_relationship_cache',
293 'entity' => 'RelationshipCache',
294 'bao' => 'CRM_Contact_BAO_RelationshipCache',
297 'type' => 'CheckBox',
301 'relationship_start_date' => [
302 'name' => 'start_date',
303 'type' => CRM_Utils_Type
::T_DATE
,
304 'title' => ts('Relationship Start Date'),
305 'description' => ts('date when the relationship started'),
306 'where' => 'civicrm_relationship_cache.start_date',
307 'table_name' => 'civicrm_relationship_cache',
308 'entity' => 'RelationshipCache',
309 'bao' => 'CRM_Contact_BAO_RelationshipCache',
312 'type' => 'Select Date',
313 'formatType' => 'activityDate',
317 'relationship_end_date' => [
318 'name' => 'end_date',
319 'type' => CRM_Utils_Type
::T_DATE
,
320 'title' => ts('Relationship End Date'),
321 'description' => ts('date when the relationship ended'),
322 'where' => 'civicrm_relationship_cache.end_date',
323 'table_name' => 'civicrm_relationship_cache',
324 'entity' => 'RelationshipCache',
325 'bao' => 'CRM_Contact_BAO_RelationshipCache',
328 'type' => 'Select Date',
329 'formatType' => 'activityDate',
334 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
336 return Civi
::$statics[__CLASS__
]['fields'];
340 * Return a mapping from field-name to the corresponding key (as used in fields()).
343 * Array(string $name => string $uniqueName).
345 public static function &fieldKeys() {
346 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
347 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
349 return Civi
::$statics[__CLASS__
]['fieldKeys'];
353 * Returns the names of this table
357 public static function getTableName() {
358 return self
::$_tableName;
362 * Returns if this table needs to be logged
366 public function getLog() {
371 * Returns the list of fields that can be imported
373 * @param bool $prefix
377 public static function &import($prefix = FALSE) {
378 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship_cache', $prefix, []);
383 * Returns the list of fields that can be exported
385 * @param bool $prefix
389 public static function &export($prefix = FALSE) {
390 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship_cache', $prefix, []);
395 * Returns the list of indices
397 * @param bool $localize
401 public static function indices($localize = TRUE) {
403 'UI_relationship' => [
404 'name' => 'UI_relationship',
406 0 => 'relationship_id',
409 'localizable' => FALSE,
411 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation',
413 'index_nearid_nearrelation' => [
414 'name' => 'index_nearid_nearrelation',
416 0 => 'near_contact_id',
417 1 => 'near_relation',
419 'localizable' => FALSE,
420 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation',
422 'index_nearid_farrelation' => [
423 'name' => 'index_nearid_farrelation',
425 0 => 'near_contact_id',
428 'localizable' => FALSE,
429 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation',
431 'index_near_relation' => [
432 'name' => 'index_near_relation',
434 0 => 'near_relation',
436 'localizable' => FALSE,
437 'sig' => 'civicrm_relationship_cache::0::near_relation',
440 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;