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:6de8ba08019ff8821fd4e09f14db6da9)
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('Relationship Caches') : ts('Relationship Cache');
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 (Near side)'),
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',
249 'pseudoconstant' => [
250 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
254 'far_contact_id' => [
255 'name' => 'far_contact_id',
256 'type' => CRM_Utils_Type
::T_INT
,
257 'title' => ts('Contact ID (Far side)'),
258 'description' => ts('id of the second contact'),
260 'where' => 'civicrm_relationship_cache.far_contact_id',
261 'table_name' => 'civicrm_relationship_cache',
262 'entity' => 'RelationshipCache',
263 'bao' => 'CRM_Contact_BAO_RelationshipCache',
265 'FKClassName' => 'CRM_Contact_DAO_Contact',
267 'type' => 'EntityRef',
272 'name' => 'far_relation',
273 'type' => CRM_Utils_Type
::T_STRING
,
274 'title' => ts('Relationship Name (Near side)'),
275 'description' => ts('name for relationship of far_contact to near_contact.'),
277 'size' => CRM_Utils_Type
::BIG
,
278 'where' => 'civicrm_relationship_cache.far_relation',
279 'table_name' => 'civicrm_relationship_cache',
280 'entity' => 'RelationshipCache',
281 'bao' => 'CRM_Contact_BAO_RelationshipCache',
283 'pseudoconstant' => [
284 'callback' => 'CRM_Core_PseudoConstant::relationshipTypeOptions',
289 'name' => 'is_active',
290 'type' => CRM_Utils_Type
::T_BOOLEAN
,
291 'title' => ts('Relationship Is Active'),
292 'description' => ts('is the relationship active ?'),
293 'where' => 'civicrm_relationship_cache.is_active',
295 'table_name' => 'civicrm_relationship_cache',
296 'entity' => 'RelationshipCache',
297 'bao' => 'CRM_Contact_BAO_RelationshipCache',
300 'type' => 'CheckBox',
304 'relationship_start_date' => [
305 'name' => 'start_date',
306 'type' => CRM_Utils_Type
::T_DATE
,
307 'title' => ts('Relationship Start Date'),
308 'description' => ts('date when the relationship started'),
309 'where' => 'civicrm_relationship_cache.start_date',
310 'table_name' => 'civicrm_relationship_cache',
311 'entity' => 'RelationshipCache',
312 'bao' => 'CRM_Contact_BAO_RelationshipCache',
315 'type' => 'Select Date',
316 'formatType' => 'activityDate',
320 'relationship_end_date' => [
321 'name' => 'end_date',
322 'type' => CRM_Utils_Type
::T_DATE
,
323 'title' => ts('Relationship End Date'),
324 'description' => ts('date when the relationship ended'),
325 'where' => 'civicrm_relationship_cache.end_date',
326 'table_name' => 'civicrm_relationship_cache',
327 'entity' => 'RelationshipCache',
328 'bao' => 'CRM_Contact_BAO_RelationshipCache',
331 'type' => 'Select Date',
332 'formatType' => 'activityDate',
337 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
339 return Civi
::$statics[__CLASS__
]['fields'];
343 * Return a mapping from field-name to the corresponding key (as used in fields()).
346 * Array(string $name => string $uniqueName).
348 public static function &fieldKeys() {
349 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
350 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
352 return Civi
::$statics[__CLASS__
]['fieldKeys'];
356 * Returns the names of this table
360 public static function getTableName() {
361 return self
::$_tableName;
365 * Returns if this table needs to be logged
369 public function getLog() {
374 * Returns the list of fields that can be imported
376 * @param bool $prefix
380 public static function &import($prefix = FALSE) {
381 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship_cache', $prefix, []);
386 * Returns the list of fields that can be exported
388 * @param bool $prefix
392 public static function &export($prefix = FALSE) {
393 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship_cache', $prefix, []);
398 * Returns the list of indices
400 * @param bool $localize
404 public static function indices($localize = TRUE) {
406 'UI_relationship' => [
407 'name' => 'UI_relationship',
409 0 => 'relationship_id',
412 'localizable' => FALSE,
414 'sig' => 'civicrm_relationship_cache::1::relationship_id::orientation',
416 'index_nearid_nearrelation' => [
417 'name' => 'index_nearid_nearrelation',
419 0 => 'near_contact_id',
420 1 => 'near_relation',
422 'localizable' => FALSE,
423 'sig' => 'civicrm_relationship_cache::0::near_contact_id::near_relation',
425 'index_nearid_farrelation' => [
426 'name' => 'index_nearid_farrelation',
428 0 => 'near_contact_id',
431 'localizable' => FALSE,
432 'sig' => 'civicrm_relationship_cache::0::near_contact_id::far_relation',
434 'index_near_relation' => [
435 'name' => 'index_near_relation',
437 0 => 'near_relation',
439 'localizable' => FALSE,
440 'sig' => 'civicrm_relationship_cache::0::near_relation',
443 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;