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:6e9767fcd0fc6eba8fcd408588fe0755)
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;
41 * name for relationship of contact_a to contact_b.
48 * label for relationship of contact_a to contact_b.
55 * Optional name for relationship of contact_b to contact_a.
62 * Optional label for relationship of contact_b to contact_a.
69 * Optional verbose description of the relationship type.
76 * If defined, contact_a in a relationship of this type must be a specific contact_type.
80 public $contact_type_a;
83 * If defined, contact_b in a relationship of this type must be a specific contact_type.
87 public $contact_type_b;
90 * If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.
94 public $contact_sub_type_a;
97 * If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.
101 public $contact_sub_type_b;
104 * Is this relationship type a predefined system type (can not be changed or de-activated)?
111 * Is this relationship type currently active (i.e. can be used when creating or editing relationships)?
120 public function __construct() {
121 $this->__table
= 'civicrm_relationship_type';
122 parent
::__construct();
126 * Returns localized title of this entity.
128 public static function getEntityTitle() {
129 return ts('Relationship Types');
133 * Returns all the column names of this table
137 public static function &fields() {
138 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
139 Civi
::$statics[__CLASS__
]['fields'] = [
142 'type' => CRM_Utils_Type
::T_INT
,
143 'title' => ts('Relationship Type ID'),
144 'description' => ts('Primary key'),
146 'where' => 'civicrm_relationship_type.id',
147 'table_name' => 'civicrm_relationship_type',
148 'entity' => 'RelationshipType',
149 'bao' => 'CRM_Contact_BAO_RelationshipType',
154 'name' => 'name_a_b',
155 'type' => CRM_Utils_Type
::T_STRING
,
156 'title' => ts('Relationship Type Name A to B'),
157 'description' => ts('name for relationship of contact_a to contact_b.'),
159 'size' => CRM_Utils_Type
::BIG
,
160 'where' => 'civicrm_relationship_type.name_a_b',
161 'table_name' => 'civicrm_relationship_type',
162 'entity' => 'RelationshipType',
163 'bao' => 'CRM_Contact_BAO_RelationshipType',
168 'name' => 'label_a_b',
169 'type' => CRM_Utils_Type
::T_STRING
,
170 'title' => ts('Relationship Type Label A to B'),
171 'description' => ts('label for relationship of contact_a to contact_b.'),
173 'size' => CRM_Utils_Type
::BIG
,
174 'where' => 'civicrm_relationship_type.label_a_b',
175 'table_name' => 'civicrm_relationship_type',
176 'entity' => 'RelationshipType',
177 'bao' => 'CRM_Contact_BAO_RelationshipType',
185 'name' => 'name_b_a',
186 'type' => CRM_Utils_Type
::T_STRING
,
187 'title' => ts('Relationship Type Name B to A'),
188 'description' => ts('Optional name for relationship of contact_b to contact_a.'),
190 'size' => CRM_Utils_Type
::BIG
,
191 'where' => 'civicrm_relationship_type.name_b_a',
192 'table_name' => 'civicrm_relationship_type',
193 'entity' => 'RelationshipType',
194 'bao' => 'CRM_Contact_BAO_RelationshipType',
199 'name' => 'label_b_a',
200 'type' => CRM_Utils_Type
::T_STRING
,
201 'title' => ts('Relationship Type Label B to A'),
202 'description' => ts('Optional label for relationship of contact_b to contact_a.'),
204 'size' => CRM_Utils_Type
::BIG
,
205 'where' => 'civicrm_relationship_type.label_b_a',
206 'table_name' => 'civicrm_relationship_type',
207 'entity' => 'RelationshipType',
208 'bao' => 'CRM_Contact_BAO_RelationshipType',
216 'name' => 'description',
217 'type' => CRM_Utils_Type
::T_STRING
,
218 'title' => ts('Relationship Description'),
219 'description' => ts('Optional verbose description of the relationship type.'),
221 'size' => CRM_Utils_Type
::HUGE
,
222 'where' => 'civicrm_relationship_type.description',
223 'table_name' => 'civicrm_relationship_type',
224 'entity' => 'RelationshipType',
225 'bao' => 'CRM_Contact_BAO_RelationshipType',
232 'contact_type_a' => [
233 'name' => 'contact_type_a',
234 'type' => CRM_Utils_Type
::T_STRING
,
235 'title' => ts('Contact Type for Contact A'),
236 'description' => ts('If defined, contact_a in a relationship of this type must be a specific contact_type.'),
238 'size' => CRM_Utils_Type
::TWELVE
,
239 'where' => 'civicrm_relationship_type.contact_type_a',
240 'table_name' => 'civicrm_relationship_type',
241 'entity' => 'RelationshipType',
242 'bao' => 'CRM_Contact_BAO_RelationshipType',
247 'pseudoconstant' => [
248 'table' => 'civicrm_contact_type',
249 'keyColumn' => 'name',
250 'labelColumn' => 'label',
251 'condition' => 'parent_id IS NULL',
255 'contact_type_b' => [
256 'name' => 'contact_type_b',
257 'type' => CRM_Utils_Type
::T_STRING
,
258 'title' => ts('Contact Type for Contact B'),
259 'description' => ts('If defined, contact_b in a relationship of this type must be a specific contact_type.'),
261 'size' => CRM_Utils_Type
::TWELVE
,
262 'where' => 'civicrm_relationship_type.contact_type_b',
263 'table_name' => 'civicrm_relationship_type',
264 'entity' => 'RelationshipType',
265 'bao' => 'CRM_Contact_BAO_RelationshipType',
270 'pseudoconstant' => [
271 'table' => 'civicrm_contact_type',
272 'keyColumn' => 'name',
273 'labelColumn' => 'label',
274 'condition' => 'parent_id IS NULL',
278 'contact_sub_type_a' => [
279 'name' => 'contact_sub_type_a',
280 'type' => CRM_Utils_Type
::T_STRING
,
281 'title' => ts('Contact Subtype A'),
282 'description' => ts('If defined, contact_sub_type_a in a relationship of this type must be a specific contact_sub_type.'),
284 'size' => CRM_Utils_Type
::BIG
,
285 'where' => 'civicrm_relationship_type.contact_sub_type_a',
286 'table_name' => 'civicrm_relationship_type',
287 'entity' => 'RelationshipType',
288 'bao' => 'CRM_Contact_BAO_RelationshipType',
293 'pseudoconstant' => [
294 'table' => 'civicrm_contact_type',
295 'keyColumn' => 'name',
296 'labelColumn' => 'label',
297 'condition' => 'parent_id IS NOT NULL',
301 'contact_sub_type_b' => [
302 'name' => 'contact_sub_type_b',
303 'type' => CRM_Utils_Type
::T_STRING
,
304 'title' => ts('Contact Subtype B'),
305 'description' => ts('If defined, contact_sub_type_b in a relationship of this type must be a specific contact_sub_type.'),
307 'size' => CRM_Utils_Type
::BIG
,
308 'where' => 'civicrm_relationship_type.contact_sub_type_b',
309 'table_name' => 'civicrm_relationship_type',
310 'entity' => 'RelationshipType',
311 'bao' => 'CRM_Contact_BAO_RelationshipType',
316 'pseudoconstant' => [
317 'table' => 'civicrm_contact_type',
318 'keyColumn' => 'name',
319 'labelColumn' => 'label',
320 'condition' => 'parent_id IS NOT NULL',
325 'name' => 'is_reserved',
326 'type' => CRM_Utils_Type
::T_BOOLEAN
,
327 'title' => ts('Relationship Type is Reserved'),
328 'description' => ts('Is this relationship type a predefined system type (can not be changed or de-activated)?'),
329 'where' => 'civicrm_relationship_type.is_reserved',
330 'table_name' => 'civicrm_relationship_type',
331 'entity' => 'RelationshipType',
332 'bao' => 'CRM_Contact_BAO_RelationshipType',
335 'type' => 'CheckBox',
340 'name' => 'is_active',
341 'type' => CRM_Utils_Type
::T_BOOLEAN
,
342 'title' => ts('Relationship Type is Active'),
343 'description' => ts('Is this relationship type currently active (i.e. can be used when creating or editing relationships)?'),
344 'where' => 'civicrm_relationship_type.is_active',
346 'table_name' => 'civicrm_relationship_type',
347 'entity' => 'RelationshipType',
348 'bao' => 'CRM_Contact_BAO_RelationshipType',
351 'type' => 'CheckBox',
356 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
358 return Civi
::$statics[__CLASS__
]['fields'];
362 * Return a mapping from field-name to the corresponding key (as used in fields()).
365 * Array(string $name => string $uniqueName).
367 public static function &fieldKeys() {
368 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
369 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
371 return Civi
::$statics[__CLASS__
]['fieldKeys'];
375 * Returns the names of this table
379 public static function getTableName() {
380 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
384 * Returns if this table needs to be logged
388 public function getLog() {
393 * Returns the list of fields that can be imported
395 * @param bool $prefix
399 public static function &import($prefix = FALSE) {
400 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship_type', $prefix, []);
405 * Returns the list of fields that can be exported
407 * @param bool $prefix
411 public static function &export($prefix = FALSE) {
412 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship_type', $prefix, []);
417 * Returns the list of indices
419 * @param bool $localize
423 public static function indices($localize = TRUE) {
426 'name' => 'UI_name_a_b',
430 'localizable' => FALSE,
432 'sig' => 'civicrm_relationship_type::1::name_a_b',
435 'name' => 'UI_name_b_a',
439 'localizable' => FALSE,
441 'sig' => 'civicrm_relationship_type::1::name_b_a',
444 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;