5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Member/Membership.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:2f2fd321dc15b2e2f453fc600d994c9a)
13 * Database access object for the Membership entity.
15 class CRM_Member_DAO_Membership
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.5';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_membership';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-id-badge';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
41 * Paths for accessing this entity in the UI.
45 protected static $_paths = [
46 'add' => 'civicrm/member/add?reset=1&action=add&context=standalone',
47 'view' => 'civicrm/contact/view/membership?reset=1&action=view&id=[id]&cid=[contact_id]',
48 'update' => 'civicrm/contact/view/membership?reset=1&action=update&id=[id]&cid=[contact_id]',
49 'delete' => 'civicrm/contact/view/membership?reset=1&action=delete&id=[id]&cid=[contact_id]',
67 * FK to Membership Type
71 public $membership_type_id;
74 * Beginning of initial membership period (member since...).
81 * Beginning of current uninterrupted membership period.
88 * Current membership period expire date.
100 * FK to Membership Status
107 * Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.
114 * Then end date of membership status override if 'Override until selected date' override type is selected.
118 public $status_override_end_date;
121 * Optional FK to Parent Membership.
125 public $owner_membership_id;
128 * Maximum number of related memberships (membership_type override).
142 public $is_pay_later;
145 * Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.
149 public $contribution_recur_id;
152 * The campaign for which this membership is attached.
161 public function __construct() {
162 $this->__table
= 'civicrm_membership';
163 parent
::__construct();
167 * Returns localized title of this entity.
169 * @param bool $plural
170 * Whether to return the plural version of the title.
172 public static function getEntityTitle($plural = FALSE) {
173 return $plural ?
ts('Memberships') : ts('Membership');
177 * Returns foreign keys and entity references.
180 * [CRM_Core_Reference_Interface]
182 public static function getReferenceColumns() {
183 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
184 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
185 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
186 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'membership_type_id', 'civicrm_membership_type', 'id');
187 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'status_id', 'civicrm_membership_status', 'id');
188 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'owner_membership_id', 'civicrm_membership', 'id');
189 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_recur_id', 'civicrm_contribution_recur', 'id');
190 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
191 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
193 return Civi
::$statics[__CLASS__
]['links'];
197 * Returns all the column names of this table
201 public static function &fields() {
202 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
203 Civi
::$statics[__CLASS__
]['fields'] = [
206 'type' => CRM_Utils_Type
::T_INT
,
207 'title' => ts('Membership ID'),
208 'description' => ts('Membership Id'),
211 'where' => 'civicrm_membership.id',
212 'headerPattern' => '/^(m(embership\s)?id)$/i',
214 'table_name' => 'civicrm_membership',
215 'entity' => 'Membership',
216 'bao' => 'CRM_Member_BAO_Membership',
220 'membership_contact_id' => [
221 'name' => 'contact_id',
222 'type' => CRM_Utils_Type
::T_INT
,
223 'title' => ts('Contact ID'),
224 'description' => ts('FK to Contact ID'),
227 'where' => 'civicrm_membership.contact_id',
228 'headerPattern' => '/contact(.?id)?/i',
229 'dataPattern' => '/^\d+$/',
231 'table_name' => 'civicrm_membership',
232 'entity' => 'Membership',
233 'bao' => 'CRM_Member_BAO_Membership',
235 'FKClassName' => 'CRM_Contact_DAO_Contact',
237 'type' => 'EntityRef',
241 'membership_type_id' => [
242 'name' => 'membership_type_id',
243 'type' => CRM_Utils_Type
::T_INT
,
244 'title' => ts('Membership Type Id'),
245 'description' => ts('FK to Membership Type'),
248 'where' => 'civicrm_membership.membership_type_id',
249 'headerPattern' => '/^(m(embership\s)?type)$/i',
251 'table_name' => 'civicrm_membership',
252 'entity' => 'Membership',
253 'bao' => 'CRM_Member_BAO_Membership',
255 'FKClassName' => 'CRM_Member_DAO_MembershipType',
258 'label' => ts("Membership Type"),
260 'pseudoconstant' => [
261 'table' => 'civicrm_membership_type',
263 'labelColumn' => 'name',
267 'membership_join_date' => [
268 'name' => 'join_date',
269 'type' => CRM_Utils_Type
::T_DATE
,
270 'title' => ts('Member Since'),
271 'description' => ts('Beginning of initial membership period (member since...).'),
273 'where' => 'civicrm_membership.join_date',
274 'headerPattern' => '/^join|(j(oin\s)?date)$/i',
275 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
277 'table_name' => 'civicrm_membership',
278 'entity' => 'Membership',
279 'bao' => 'CRM_Member_BAO_Membership',
282 'type' => 'Select Date',
283 'formatType' => 'activityDate',
287 'membership_start_date' => [
288 'name' => 'start_date',
289 'type' => CRM_Utils_Type
::T_DATE
,
290 'title' => ts('Membership Start Date'),
291 'description' => ts('Beginning of current uninterrupted membership period.'),
293 'where' => 'civicrm_membership.start_date',
294 'headerPattern' => '/(member(ship)?.)?start(s)?(.date$)?/i',
295 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
297 'table_name' => 'civicrm_membership',
298 'entity' => 'Membership',
299 'bao' => 'CRM_Member_BAO_Membership',
302 'type' => 'Select Date',
303 'formatType' => 'activityDate',
307 'membership_end_date' => [
308 'name' => 'end_date',
309 'type' => CRM_Utils_Type
::T_DATE
,
310 'title' => ts('Membership Expiration Date'),
311 'description' => ts('Current membership period expire date.'),
313 'where' => 'civicrm_membership.end_date',
314 'headerPattern' => '/(member(ship)?.)?end(s)?(.date$)?/i',
315 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
317 'table_name' => 'civicrm_membership',
318 'entity' => 'Membership',
319 'bao' => 'CRM_Member_BAO_Membership',
322 'type' => 'Select Date',
323 'formatType' => 'activityDate',
327 'membership_source' => [
329 'type' => CRM_Utils_Type
::T_STRING
,
330 'title' => ts('Source'),
332 'size' => CRM_Utils_Type
::HUGE
,
334 'where' => 'civicrm_membership.source',
335 'headerPattern' => '/^(member(ship?))?source$/i',
337 'table_name' => 'civicrm_membership',
338 'entity' => 'Membership',
339 'bao' => 'CRM_Member_BAO_Membership',
347 'name' => 'status_id',
348 'type' => CRM_Utils_Type
::T_INT
,
349 'title' => ts('Membership Status Id'),
350 'description' => ts('FK to Membership Status'),
353 'where' => 'civicrm_membership.status_id',
354 'headerPattern' => '/(member(ship|).)?(status)$/i',
356 'table_name' => 'civicrm_membership',
357 'entity' => 'Membership',
358 'bao' => 'CRM_Member_BAO_Membership',
360 'FKClassName' => 'CRM_Member_DAO_MembershipStatus',
364 'pseudoconstant' => [
365 'table' => 'civicrm_membership_status',
367 'labelColumn' => 'label',
371 'member_is_override' => [
372 'name' => 'is_override',
373 'type' => CRM_Utils_Type
::T_BOOLEAN
,
374 'title' => ts('Status Override'),
375 'description' => ts('Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.'),
377 'where' => 'civicrm_membership.is_override',
378 'headerPattern' => '/override$/i',
380 'table_name' => 'civicrm_membership',
381 'entity' => 'Membership',
382 'bao' => 'CRM_Member_BAO_Membership',
385 'type' => 'CheckBox',
389 'status_override_end_date' => [
390 'name' => 'status_override_end_date',
391 'type' => CRM_Utils_Type
::T_DATE
,
392 'title' => ts('Status Override End Date'),
393 'description' => ts('Then end date of membership status override if \'Override until selected date\' override type is selected.'),
395 'where' => 'civicrm_membership.status_override_end_date',
398 'table_name' => 'civicrm_membership',
399 'entity' => 'Membership',
400 'bao' => 'CRM_Member_BAO_Membership',
403 'type' => 'Select Date',
404 'formatType' => 'activityDate',
408 'owner_membership_id' => [
409 'name' => 'owner_membership_id',
410 'type' => CRM_Utils_Type
::T_INT
,
411 'title' => ts('Primary Member ID'),
412 'description' => ts('Optional FK to Parent Membership.'),
413 'where' => 'civicrm_membership.owner_membership_id',
415 'table_name' => 'civicrm_membership',
416 'entity' => 'Membership',
417 'bao' => 'CRM_Member_BAO_Membership',
419 'FKClassName' => 'CRM_Member_DAO_Membership',
423 'name' => 'max_related',
424 'type' => CRM_Utils_Type
::T_INT
,
425 'title' => ts('Max Related'),
426 'description' => ts('Maximum number of related memberships (membership_type override).'),
427 'where' => 'civicrm_membership.max_related',
429 'table_name' => 'civicrm_membership',
430 'entity' => 'Membership',
431 'bao' => 'CRM_Member_BAO_Membership',
438 'member_is_test' => [
440 'type' => CRM_Utils_Type
::T_BOOLEAN
,
441 'title' => ts('Test'),
443 'where' => 'civicrm_membership.is_test',
444 'headerPattern' => '/(is.)?test(.member(ship)?)?/i',
447 'table_name' => 'civicrm_membership',
448 'entity' => 'Membership',
449 'bao' => 'CRM_Member_BAO_Membership',
452 'type' => 'CheckBox',
456 'member_is_pay_later' => [
457 'name' => 'is_pay_later',
458 'type' => CRM_Utils_Type
::T_BOOLEAN
,
459 'title' => ts('Is Pay Later'),
461 'where' => 'civicrm_membership.is_pay_later',
462 'headerPattern' => '/(is.)?(pay(.)?later)$/i',
465 'table_name' => 'civicrm_membership',
466 'entity' => 'Membership',
467 'bao' => 'CRM_Member_BAO_Membership',
470 'type' => 'CheckBox',
474 'membership_recur_id' => [
475 'name' => 'contribution_recur_id',
476 'type' => CRM_Utils_Type
::T_INT
,
477 'title' => ts('Membership Recurring Contribution'),
478 'description' => ts('Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.'),
479 'where' => 'civicrm_membership.contribution_recur_id',
481 'table_name' => 'civicrm_membership',
482 'entity' => 'Membership',
483 'bao' => 'CRM_Member_BAO_Membership',
485 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
488 'member_campaign_id' => [
489 'name' => 'campaign_id',
490 'type' => CRM_Utils_Type
::T_INT
,
491 'title' => ts('Campaign'),
492 'description' => ts('The campaign for which this membership is attached.'),
494 'where' => 'civicrm_membership.campaign_id',
496 'table_name' => 'civicrm_membership',
497 'entity' => 'Membership',
498 'bao' => 'CRM_Member_BAO_Membership',
500 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
504 'pseudoconstant' => [
505 'table' => 'civicrm_campaign',
507 'labelColumn' => 'title',
512 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
514 return Civi
::$statics[__CLASS__
]['fields'];
518 * Return a mapping from field-name to the corresponding key (as used in fields()).
521 * Array(string $name => string $uniqueName).
523 public static function &fieldKeys() {
524 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
525 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
527 return Civi
::$statics[__CLASS__
]['fieldKeys'];
531 * Returns the names of this table
535 public static function getTableName() {
536 return self
::$_tableName;
540 * Returns if this table needs to be logged
544 public function getLog() {
549 * Returns the list of fields that can be imported
551 * @param bool $prefix
555 public static function &import($prefix = FALSE) {
556 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'membership', $prefix, []);
561 * Returns the list of fields that can be exported
563 * @param bool $prefix
567 public static function &export($prefix = FALSE) {
568 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'membership', $prefix, []);
573 * Returns the list of indices
575 * @param bool $localize
579 public static function indices($localize = TRUE) {
581 'index_owner_membership_id' => [
582 'name' => 'index_owner_membership_id',
584 0 => 'owner_membership_id',
586 'localizable' => FALSE,
587 'sig' => 'civicrm_membership::0::owner_membership_id',
590 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;