5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contact/Relationship.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:b1e83f9c102db77881c4b9c730f38337)
13 * Database access object for the Relationship entity.
15 class CRM_Contact_DAO_Relationship
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_relationship';
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 = TRUE;
46 * id of the first contact
53 * id of the second contact
60 * id of the relationship
64 public $relationship_type_id;
67 * date when the relationship started
74 * date when the relationship ended
81 * is the relationship active ?
88 * Optional verbose description for the relationship.
95 * Permission that Contact A has to view/update Contact B
99 public $is_permission_a_b;
102 * Permission that Contact B has to view/update Contact A
106 public $is_permission_b_a;
118 public function __construct() {
119 $this->__table
= 'civicrm_relationship';
120 parent
::__construct();
124 * Returns localized title of this entity.
126 public static function getEntityTitle() {
127 return ts('Relationships');
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(), 'contact_id_a', 'civicrm_contact', 'id');
140 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_b', 'civicrm_contact', 'id');
141 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
142 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_id', 'civicrm_case', '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 ID'),
160 'description' => ts('Relationship ID'),
162 'where' => 'civicrm_relationship.id',
163 'table_name' => 'civicrm_relationship',
164 'entity' => 'Relationship',
165 'bao' => 'CRM_Contact_BAO_Relationship',
170 'name' => 'contact_id_a',
171 'type' => CRM_Utils_Type
::T_INT
,
172 'title' => ts('Contact A'),
173 'description' => ts('id of the first contact'),
175 'where' => 'civicrm_relationship.contact_id_a',
176 'table_name' => 'civicrm_relationship',
177 'entity' => 'Relationship',
178 'bao' => 'CRM_Contact_BAO_Relationship',
180 'FKClassName' => 'CRM_Contact_DAO_Contact',
184 'name' => 'contact_id_b',
185 'type' => CRM_Utils_Type
::T_INT
,
186 'title' => ts('Contact B'),
187 'description' => ts('id of the second contact'),
189 'where' => 'civicrm_relationship.contact_id_b',
190 'table_name' => 'civicrm_relationship',
191 'entity' => 'Relationship',
192 'bao' => 'CRM_Contact_BAO_Relationship',
194 'FKClassName' => 'CRM_Contact_DAO_Contact',
196 'type' => 'EntityRef',
200 'relationship_type_id' => [
201 'name' => 'relationship_type_id',
202 'type' => CRM_Utils_Type
::T_INT
,
203 'title' => ts('Relationship Type'),
204 'description' => ts('id of the relationship'),
206 'where' => 'civicrm_relationship.relationship_type_id',
207 'table_name' => 'civicrm_relationship',
208 'entity' => 'Relationship',
209 'bao' => 'CRM_Contact_BAO_Relationship',
211 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
217 'relationship_start_date' => [
218 'name' => 'start_date',
219 'type' => CRM_Utils_Type
::T_DATE
,
220 'title' => ts('Relationship Start Date'),
221 'description' => ts('date when the relationship started'),
222 'where' => 'civicrm_relationship.start_date',
223 'table_name' => 'civicrm_relationship',
224 'entity' => 'Relationship',
225 'bao' => 'CRM_Contact_BAO_Relationship',
228 'type' => 'Select Date',
229 'formatType' => 'activityDate',
233 'relationship_end_date' => [
234 'name' => 'end_date',
235 'type' => CRM_Utils_Type
::T_DATE
,
236 'title' => ts('Relationship End Date'),
237 'description' => ts('date when the relationship ended'),
238 'where' => 'civicrm_relationship.end_date',
239 'table_name' => 'civicrm_relationship',
240 'entity' => 'Relationship',
241 'bao' => 'CRM_Contact_BAO_Relationship',
244 'type' => 'Select Date',
245 'formatType' => 'activityDate',
250 'name' => 'is_active',
251 'type' => CRM_Utils_Type
::T_BOOLEAN
,
252 'title' => ts('Relationship Is Active'),
253 'description' => ts('is the relationship active ?'),
254 'where' => 'civicrm_relationship.is_active',
256 'table_name' => 'civicrm_relationship',
257 'entity' => 'Relationship',
258 'bao' => 'CRM_Contact_BAO_Relationship',
261 'type' => 'CheckBox',
266 'name' => 'description',
267 'type' => CRM_Utils_Type
::T_STRING
,
268 'title' => ts('Relationship Description'),
269 'description' => ts('Optional verbose description for the relationship.'),
271 'size' => CRM_Utils_Type
::HUGE
,
272 'where' => 'civicrm_relationship.description',
273 'table_name' => 'civicrm_relationship',
274 'entity' => 'Relationship',
275 'bao' => 'CRM_Contact_BAO_Relationship',
282 'is_permission_a_b' => [
283 'name' => 'is_permission_a_b',
284 'type' => CRM_Utils_Type
::T_INT
,
285 'title' => ts('Contact A has Permission Over Contact B'),
286 'description' => ts('Permission that Contact A has to view/update Contact B'),
288 'where' => 'civicrm_relationship.is_permission_a_b',
290 'table_name' => 'civicrm_relationship',
291 'entity' => 'Relationship',
292 'bao' => 'CRM_Contact_BAO_Relationship',
297 'pseudoconstant' => [
298 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
302 'is_permission_b_a' => [
303 'name' => 'is_permission_b_a',
304 'type' => CRM_Utils_Type
::T_INT
,
305 'title' => ts('Contact B has Permission Over Contact A'),
306 'description' => ts('Permission that Contact B has to view/update Contact A'),
308 'where' => 'civicrm_relationship.is_permission_b_a',
310 'table_name' => 'civicrm_relationship',
311 'entity' => 'Relationship',
312 'bao' => 'CRM_Contact_BAO_Relationship',
317 'pseudoconstant' => [
318 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
324 'type' => CRM_Utils_Type
::T_INT
,
325 'title' => ts('Relationship Case'),
326 'description' => ts('FK to civicrm_case'),
327 'where' => 'civicrm_relationship.case_id',
329 'table_name' => 'civicrm_relationship',
330 'entity' => 'Relationship',
331 'bao' => 'CRM_Contact_BAO_Relationship',
333 'FKClassName' => 'CRM_Case_DAO_Case',
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', $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', $prefix, []);
398 * Returns the list of indices
400 * @param bool $localize
404 public static function indices($localize = TRUE) {
406 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;