5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contact/RelationshipType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:f420b1007ffa4e74cd3e23e34133f170)
13 * Database access object for the RelationshipType entity.
15 class CRM_Contact_DAO_RelationshipType
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_relationship_type';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = TRUE;
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
43 * name for relationship of contact_a to contact_b.
46 * (SQL type: varchar(64))
47 * Note that values will be retrieved from the database as a string.
52 * label for relationship of contact_a to contact_b.
55 * (SQL type: varchar(64))
56 * Note that values will be retrieved from the database as a string.
61 * Optional name for relationship of contact_b to contact_a.
64 * (SQL type: varchar(64))
65 * Note that values will be retrieved from the database as a string.
70 * Optional label for relationship of contact_b to contact_a.
73 * (SQL type: varchar(64))
74 * Note that values will be retrieved from the database as a string.
79 * Optional verbose description of the relationship type.
82 * (SQL type: varchar(255))
83 * Note that values will be retrieved from the database as a string.
88 * If defined, contact_a in a relationship of this type must be a specific contact_type.
91 * (SQL type: varchar(12))
92 * Note that values will be retrieved from the database as a string.
94 public $contact_type_a;
97 * If defined, contact_b in a relationship of this type must be a specific contact_type.
100 * (SQL type: varchar(12))
101 * Note that values will be retrieved from the database as a string.
103 public $contact_type_b;
106 * If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.
109 * (SQL type: varchar(64))
110 * Note that values will be retrieved from the database as a string.
112 public $contact_sub_type_a;
115 * If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.
118 * (SQL type: varchar(64))
119 * Note that values will be retrieved from the database as a string.
121 public $contact_sub_type_b;
124 * Is this relationship type a predefined system type (can not be changed or de-activated)?
127 * (SQL type: tinyint)
128 * Note that values will be retrieved from the database as a string.
133 * Is this relationship type currently active (i.e. can be used when creating or editing relationships)?
136 * (SQL type: tinyint)
137 * Note that values will be retrieved from the database as a string.
144 public function __construct() {
145 $this->__table
= 'civicrm_relationship_type';
146 parent
::__construct();
150 * Returns localized title of this entity.
152 * @param bool $plural
153 * Whether to return the plural version of the title.
155 public static function getEntityTitle($plural = FALSE) {
156 return $plural ?
ts('Relationship Types') : ts('Relationship Type');
160 * Returns all the column names of this table
164 public static function &fields() {
165 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
166 Civi
::$statics[__CLASS__
]['fields'] = [
169 'type' => CRM_Utils_Type
::T_INT
,
170 'title' => ts('Relationship Type ID'),
171 'description' => ts('Primary key'),
173 'where' => 'civicrm_relationship_type.id',
174 'table_name' => 'civicrm_relationship_type',
175 'entity' => 'RelationshipType',
176 'bao' => 'CRM_Contact_BAO_RelationshipType',
185 'name' => 'name_a_b',
186 'type' => CRM_Utils_Type
::T_STRING
,
187 'title' => ts('Relationship Type Name A to B'),
188 'description' => ts('name for relationship of contact_a to contact_b.'),
190 'size' => CRM_Utils_Type
::BIG
,
191 'where' => 'civicrm_relationship_type.name_a_b',
192 'table_name' => 'civicrm_relationship_type',
193 'entity' => 'RelationshipType',
194 'bao' => 'CRM_Contact_BAO_RelationshipType',
199 'name' => 'label_a_b',
200 'type' => CRM_Utils_Type
::T_STRING
,
201 'title' => ts('Relationship Type Label A to B'),
202 'description' => ts('label for relationship of contact_a to contact_b.'),
204 'size' => CRM_Utils_Type
::BIG
,
205 'where' => 'civicrm_relationship_type.label_a_b',
206 'table_name' => 'civicrm_relationship_type',
207 'entity' => 'RelationshipType',
208 'bao' => 'CRM_Contact_BAO_RelationshipType',
216 'name' => 'name_b_a',
217 'type' => CRM_Utils_Type
::T_STRING
,
218 'title' => ts('Relationship Type Name B to A'),
219 'description' => ts('Optional name for relationship of contact_b to contact_a.'),
221 'size' => CRM_Utils_Type
::BIG
,
222 'where' => 'civicrm_relationship_type.name_b_a',
223 'table_name' => 'civicrm_relationship_type',
224 'entity' => 'RelationshipType',
225 'bao' => 'CRM_Contact_BAO_RelationshipType',
230 'name' => 'label_b_a',
231 'type' => CRM_Utils_Type
::T_STRING
,
232 'title' => ts('Relationship Type Label B to A'),
233 'description' => ts('Optional label for relationship of contact_b to contact_a.'),
235 'size' => CRM_Utils_Type
::BIG
,
236 'where' => 'civicrm_relationship_type.label_b_a',
237 'table_name' => 'civicrm_relationship_type',
238 'entity' => 'RelationshipType',
239 'bao' => 'CRM_Contact_BAO_RelationshipType',
247 'name' => 'description',
248 'type' => CRM_Utils_Type
::T_STRING
,
249 'title' => ts('Relationship Description'),
250 'description' => ts('Optional verbose description of the relationship type.'),
252 'size' => CRM_Utils_Type
::HUGE
,
253 'where' => 'civicrm_relationship_type.description',
254 'table_name' => 'civicrm_relationship_type',
255 'entity' => 'RelationshipType',
256 'bao' => 'CRM_Contact_BAO_RelationshipType',
263 'contact_type_a' => [
264 'name' => 'contact_type_a',
265 'type' => CRM_Utils_Type
::T_STRING
,
266 'title' => ts('Contact Type for Contact A'),
267 'description' => ts('If defined, contact_a in a relationship of this type must be a specific contact_type.'),
269 'size' => CRM_Utils_Type
::TWELVE
,
270 'where' => 'civicrm_relationship_type.contact_type_a',
271 'table_name' => 'civicrm_relationship_type',
272 'entity' => 'RelationshipType',
273 'bao' => 'CRM_Contact_BAO_RelationshipType',
278 'pseudoconstant' => [
279 'table' => 'civicrm_contact_type',
280 'keyColumn' => 'name',
281 'labelColumn' => 'label',
282 'condition' => 'parent_id IS NULL',
286 'contact_type_b' => [
287 'name' => 'contact_type_b',
288 'type' => CRM_Utils_Type
::T_STRING
,
289 'title' => ts('Contact Type for Contact B'),
290 'description' => ts('If defined, contact_b in a relationship of this type must be a specific contact_type.'),
292 'size' => CRM_Utils_Type
::TWELVE
,
293 'where' => 'civicrm_relationship_type.contact_type_b',
294 'table_name' => 'civicrm_relationship_type',
295 'entity' => 'RelationshipType',
296 'bao' => 'CRM_Contact_BAO_RelationshipType',
301 'pseudoconstant' => [
302 'table' => 'civicrm_contact_type',
303 'keyColumn' => 'name',
304 'labelColumn' => 'label',
305 'condition' => 'parent_id IS NULL',
309 'contact_sub_type_a' => [
310 'name' => 'contact_sub_type_a',
311 'type' => CRM_Utils_Type
::T_STRING
,
312 'title' => ts('Contact Subtype A'),
313 'description' => ts('If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.'),
315 'size' => CRM_Utils_Type
::BIG
,
316 'where' => 'civicrm_relationship_type.contact_sub_type_a',
317 'table_name' => 'civicrm_relationship_type',
318 'entity' => 'RelationshipType',
319 'bao' => 'CRM_Contact_BAO_RelationshipType',
324 'pseudoconstant' => [
325 'table' => 'civicrm_contact_type',
326 'keyColumn' => 'name',
327 'labelColumn' => 'label',
328 'condition' => 'parent_id IS NOT NULL',
332 'contact_sub_type_b' => [
333 'name' => 'contact_sub_type_b',
334 'type' => CRM_Utils_Type
::T_STRING
,
335 'title' => ts('Contact Subtype B'),
336 'description' => ts('If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.'),
338 'size' => CRM_Utils_Type
::BIG
,
339 'where' => 'civicrm_relationship_type.contact_sub_type_b',
340 'table_name' => 'civicrm_relationship_type',
341 'entity' => 'RelationshipType',
342 'bao' => 'CRM_Contact_BAO_RelationshipType',
347 'pseudoconstant' => [
348 'table' => 'civicrm_contact_type',
349 'keyColumn' => 'name',
350 'labelColumn' => 'label',
351 'condition' => 'parent_id IS NOT NULL',
356 'name' => 'is_reserved',
357 'type' => CRM_Utils_Type
::T_BOOLEAN
,
358 'title' => ts('Relationship Type is Reserved'),
359 'description' => ts('Is this relationship type a predefined system type (can not be changed or de-activated)?'),
361 'where' => 'civicrm_relationship_type.is_reserved',
363 'table_name' => 'civicrm_relationship_type',
364 'entity' => 'RelationshipType',
365 'bao' => 'CRM_Contact_BAO_RelationshipType',
368 'type' => 'CheckBox',
373 'name' => 'is_active',
374 'type' => CRM_Utils_Type
::T_BOOLEAN
,
375 'title' => ts('Relationship Type is Active'),
376 'description' => ts('Is this relationship type currently active (i.e. can be used when creating or editing relationships)?'),
378 'where' => 'civicrm_relationship_type.is_active',
380 'table_name' => 'civicrm_relationship_type',
381 'entity' => 'RelationshipType',
382 'bao' => 'CRM_Contact_BAO_RelationshipType',
385 'type' => 'CheckBox',
390 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
392 return Civi
::$statics[__CLASS__
]['fields'];
396 * Return a mapping from field-name to the corresponding key (as used in fields()).
399 * Array(string $name => string $uniqueName).
401 public static function &fieldKeys() {
402 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
403 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
405 return Civi
::$statics[__CLASS__
]['fieldKeys'];
409 * Returns the names of this table
413 public static function getTableName() {
414 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
418 * Returns if this table needs to be logged
422 public function getLog() {
427 * Returns the list of fields that can be imported
429 * @param bool $prefix
433 public static function &import($prefix = FALSE) {
434 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship_type', $prefix, []);
439 * Returns the list of fields that can be exported
441 * @param bool $prefix
445 public static function &export($prefix = FALSE) {
446 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship_type', $prefix, []);
451 * Returns the list of indices
453 * @param bool $localize
457 public static function indices($localize = TRUE) {
460 'name' => 'UI_name_a_b',
464 'localizable' => FALSE,
466 'sig' => 'civicrm_relationship_type::1::name_a_b',
469 'name' => 'UI_name_b_a',
473 'localizable' => FALSE,
475 'sig' => 'civicrm_relationship_type::1::name_b_a',
478 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;