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:376227269d8c1c224c357387d0862a9f)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
39 * id of the first contact
46 * id of the second contact
53 * id of the relationship
57 public $relationship_type_id;
60 * date when the relationship started
67 * date when the relationship ended
74 * is the relationship active ?
81 * Optional verbose description for the relationship.
88 * Permission that Contact A has to view/update Contact B
92 public $is_permission_a_b;
95 * Permission that Contact B has to view/update Contact A
99 public $is_permission_b_a;
111 public function __construct() {
112 $this->__table
= 'civicrm_relationship';
113 parent
::__construct();
117 * Returns foreign keys and entity references.
120 * [CRM_Core_Reference_Interface]
122 public static function getReferenceColumns() {
123 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
124 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
125 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_a', 'civicrm_contact', 'id');
126 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id_b', 'civicrm_contact', 'id');
127 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id');
128 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'case_id', 'civicrm_case', 'id');
129 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
131 return Civi
::$statics[__CLASS__
]['links'];
135 * Returns all the column names of this table
139 public static function &fields() {
140 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
141 Civi
::$statics[__CLASS__
]['fields'] = [
144 'type' => CRM_Utils_Type
::T_INT
,
145 'title' => ts('Relationship ID'),
146 'description' => ts('Relationship ID'),
148 'where' => 'civicrm_relationship.id',
149 'table_name' => 'civicrm_relationship',
150 'entity' => 'Relationship',
151 'bao' => 'CRM_Contact_BAO_Relationship',
155 'name' => 'contact_id_a',
156 'type' => CRM_Utils_Type
::T_INT
,
157 'title' => ts('Contact A'),
158 'description' => ts('id of the first contact'),
160 'where' => 'civicrm_relationship.contact_id_a',
161 'table_name' => 'civicrm_relationship',
162 'entity' => 'Relationship',
163 'bao' => 'CRM_Contact_BAO_Relationship',
165 'FKClassName' => 'CRM_Contact_DAO_Contact',
168 'name' => 'contact_id_b',
169 'type' => CRM_Utils_Type
::T_INT
,
170 'title' => ts('Contact B'),
171 'description' => ts('id of the second contact'),
173 'where' => 'civicrm_relationship.contact_id_b',
174 'table_name' => 'civicrm_relationship',
175 'entity' => 'Relationship',
176 'bao' => 'CRM_Contact_BAO_Relationship',
178 'FKClassName' => 'CRM_Contact_DAO_Contact',
180 'type' => 'EntityRef',
183 'relationship_type_id' => [
184 'name' => 'relationship_type_id',
185 'type' => CRM_Utils_Type
::T_INT
,
186 'title' => ts('Relationship Type'),
187 'description' => ts('id of the relationship'),
189 'where' => 'civicrm_relationship.relationship_type_id',
190 'table_name' => 'civicrm_relationship',
191 'entity' => 'Relationship',
192 'bao' => 'CRM_Contact_BAO_Relationship',
194 'FKClassName' => 'CRM_Contact_DAO_RelationshipType',
199 'relationship_start_date' => [
200 'name' => 'start_date',
201 'type' => CRM_Utils_Type
::T_DATE
,
202 'title' => ts('Relationship Start Date'),
203 'description' => ts('date when the relationship started'),
204 'where' => 'civicrm_relationship.start_date',
205 'table_name' => 'civicrm_relationship',
206 'entity' => 'Relationship',
207 'bao' => 'CRM_Contact_BAO_Relationship',
210 'type' => 'Select Date',
211 'formatType' => 'activityDate',
214 'relationship_end_date' => [
215 'name' => 'end_date',
216 'type' => CRM_Utils_Type
::T_DATE
,
217 'title' => ts('Relationship End Date'),
218 'description' => ts('date when the relationship ended'),
219 'where' => 'civicrm_relationship.end_date',
220 'table_name' => 'civicrm_relationship',
221 'entity' => 'Relationship',
222 'bao' => 'CRM_Contact_BAO_Relationship',
225 'type' => 'Select Date',
226 'formatType' => 'activityDate',
230 'name' => 'is_active',
231 'type' => CRM_Utils_Type
::T_BOOLEAN
,
232 'title' => ts('Relationship Is Active'),
233 'description' => ts('is the relationship active ?'),
234 'where' => 'civicrm_relationship.is_active',
236 'table_name' => 'civicrm_relationship',
237 'entity' => 'Relationship',
238 'bao' => 'CRM_Contact_BAO_Relationship',
241 'type' => 'CheckBox',
245 'name' => 'description',
246 'type' => CRM_Utils_Type
::T_STRING
,
247 'title' => ts('Relationship Description'),
248 'description' => ts('Optional verbose description for the relationship.'),
250 'size' => CRM_Utils_Type
::HUGE
,
251 'where' => 'civicrm_relationship.description',
252 'table_name' => 'civicrm_relationship',
253 'entity' => 'Relationship',
254 'bao' => 'CRM_Contact_BAO_Relationship',
260 'is_permission_a_b' => [
261 'name' => 'is_permission_a_b',
262 'type' => CRM_Utils_Type
::T_INT
,
263 'title' => ts('Contact A has Permission Over Contact B'),
264 'description' => ts('Permission that Contact A has to view/update Contact B'),
266 'where' => 'civicrm_relationship.is_permission_a_b',
268 'table_name' => 'civicrm_relationship',
269 'entity' => 'Relationship',
270 'bao' => 'CRM_Contact_BAO_Relationship',
275 'pseudoconstant' => [
276 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
279 'is_permission_b_a' => [
280 'name' => 'is_permission_b_a',
281 'type' => CRM_Utils_Type
::T_INT
,
282 'title' => ts('Contact B has Permission Over Contact A'),
283 'description' => ts('Permission that Contact B has to view/update Contact A'),
285 'where' => 'civicrm_relationship.is_permission_b_a',
287 'table_name' => 'civicrm_relationship',
288 'entity' => 'Relationship',
289 'bao' => 'CRM_Contact_BAO_Relationship',
294 'pseudoconstant' => [
295 'callback' => 'CRM_Core_SelectValues::getPermissionedRelationshipOptions',
300 'type' => CRM_Utils_Type
::T_INT
,
301 'title' => ts('Relationship Case'),
302 'description' => ts('FK to civicrm_case'),
303 'where' => 'civicrm_relationship.case_id',
305 'table_name' => 'civicrm_relationship',
306 'entity' => 'Relationship',
307 'bao' => 'CRM_Contact_BAO_Relationship',
309 'FKClassName' => 'CRM_Case_DAO_Case',
312 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
314 return Civi
::$statics[__CLASS__
]['fields'];
318 * Return a mapping from field-name to the corresponding key (as used in fields()).
321 * Array(string $name => string $uniqueName).
323 public static function &fieldKeys() {
324 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
325 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
327 return Civi
::$statics[__CLASS__
]['fieldKeys'];
331 * Returns the names of this table
335 public static function getTableName() {
336 return self
::$_tableName;
340 * Returns if this table needs to be logged
344 public function getLog() {
349 * Returns the list of fields that can be imported
351 * @param bool $prefix
355 public static function &import($prefix = FALSE) {
356 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'relationship', $prefix, []);
361 * Returns the list of fields that can be exported
363 * @param bool $prefix
367 public static function &export($prefix = FALSE) {
368 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'relationship', $prefix, []);
373 * Returns the list of indices
375 * @param bool $localize
379 public static function indices($localize = TRUE) {
381 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;