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:d80be256fb175b763047883b8694559c)
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;
55 * FK to Membership Type
59 public $membership_type_id;
62 * Beginning of initial membership period (member since...).
69 * Beginning of current uninterrupted membership period.
76 * Current membership period expire date.
88 * FK to Membership Status
95 * 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.
102 * Then end date of membership status override if 'Override until selected date' override type is selected.
106 public $status_override_end_date;
109 * Optional FK to Parent Membership.
113 public $owner_membership_id;
116 * Maximum number of related memberships (membership_type override).
130 public $is_pay_later;
133 * 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.
137 public $contribution_recur_id;
140 * The campaign for which this membership is attached.
149 public function __construct() {
150 $this->__table
= 'civicrm_membership';
151 parent
::__construct();
155 * Returns localized title of this entity.
157 * @param bool $plural
158 * Whether to return the plural version of the title.
160 public static function getEntityTitle($plural = FALSE) {
161 return $plural ?
ts('Memberships') : ts('Membership');
165 * Returns foreign keys and entity references.
168 * [CRM_Core_Reference_Interface]
170 public static function getReferenceColumns() {
171 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
172 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
173 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
174 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'membership_type_id', 'civicrm_membership_type', 'id');
175 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'status_id', 'civicrm_membership_status', 'id');
176 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'owner_membership_id', 'civicrm_membership', 'id');
177 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_recur_id', 'civicrm_contribution_recur', 'id');
178 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
179 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
181 return Civi
::$statics[__CLASS__
]['links'];
185 * Returns all the column names of this table
189 public static function &fields() {
190 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
191 Civi
::$statics[__CLASS__
]['fields'] = [
194 'type' => CRM_Utils_Type
::T_INT
,
195 'title' => ts('Membership ID'),
196 'description' => ts('Membership Id'),
199 'where' => 'civicrm_membership.id',
200 'headerPattern' => '/^(m(embership\s)?id)$/i',
202 'table_name' => 'civicrm_membership',
203 'entity' => 'Membership',
204 'bao' => 'CRM_Member_BAO_Membership',
208 'membership_contact_id' => [
209 'name' => 'contact_id',
210 'type' => CRM_Utils_Type
::T_INT
,
211 'title' => ts('Contact ID'),
212 'description' => ts('FK to Contact ID'),
215 'where' => 'civicrm_membership.contact_id',
216 'headerPattern' => '/contact(.?id)?/i',
217 'dataPattern' => '/^\d+$/',
219 'table_name' => 'civicrm_membership',
220 'entity' => 'Membership',
221 'bao' => 'CRM_Member_BAO_Membership',
223 'FKClassName' => 'CRM_Contact_DAO_Contact',
225 'type' => 'EntityRef',
229 'membership_type_id' => [
230 'name' => 'membership_type_id',
231 'type' => CRM_Utils_Type
::T_INT
,
232 'title' => ts('Membership Type Id'),
233 'description' => ts('FK to Membership Type'),
236 'where' => 'civicrm_membership.membership_type_id',
237 'headerPattern' => '/^(m(embership\s)?type)$/i',
239 'table_name' => 'civicrm_membership',
240 'entity' => 'Membership',
241 'bao' => 'CRM_Member_BAO_Membership',
243 'FKClassName' => 'CRM_Member_DAO_MembershipType',
246 'label' => ts("Membership Type"),
248 'pseudoconstant' => [
249 'table' => 'civicrm_membership_type',
251 'labelColumn' => 'name',
255 'membership_join_date' => [
256 'name' => 'join_date',
257 'type' => CRM_Utils_Type
::T_DATE
,
258 'title' => ts('Member Since'),
259 'description' => ts('Beginning of initial membership period (member since...).'),
261 'where' => 'civicrm_membership.join_date',
262 'headerPattern' => '/^join|(j(oin\s)?date)$/i',
263 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
265 'table_name' => 'civicrm_membership',
266 'entity' => 'Membership',
267 'bao' => 'CRM_Member_BAO_Membership',
270 'type' => 'Select Date',
271 'formatType' => 'activityDate',
275 'membership_start_date' => [
276 'name' => 'start_date',
277 'type' => CRM_Utils_Type
::T_DATE
,
278 'title' => ts('Membership Start Date'),
279 'description' => ts('Beginning of current uninterrupted membership period.'),
281 'where' => 'civicrm_membership.start_date',
282 'headerPattern' => '/(member(ship)?.)?start(s)?(.date$)?/i',
283 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
285 'table_name' => 'civicrm_membership',
286 'entity' => 'Membership',
287 'bao' => 'CRM_Member_BAO_Membership',
290 'type' => 'Select Date',
291 'formatType' => 'activityDate',
295 'membership_end_date' => [
296 'name' => 'end_date',
297 'type' => CRM_Utils_Type
::T_DATE
,
298 'title' => ts('Membership Expiration Date'),
299 'description' => ts('Current membership period expire date.'),
301 'where' => 'civicrm_membership.end_date',
302 'headerPattern' => '/(member(ship)?.)?end(s)?(.date$)?/i',
303 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
305 'table_name' => 'civicrm_membership',
306 'entity' => 'Membership',
307 'bao' => 'CRM_Member_BAO_Membership',
310 'type' => 'Select Date',
311 'formatType' => 'activityDate',
315 'membership_source' => [
317 'type' => CRM_Utils_Type
::T_STRING
,
318 'title' => ts('Source'),
320 'size' => CRM_Utils_Type
::HUGE
,
322 'where' => 'civicrm_membership.source',
323 'headerPattern' => '/^(member(ship?))?source$/i',
325 'table_name' => 'civicrm_membership',
326 'entity' => 'Membership',
327 'bao' => 'CRM_Member_BAO_Membership',
335 'name' => 'status_id',
336 'type' => CRM_Utils_Type
::T_INT
,
337 'title' => ts('Membership Status Id'),
338 'description' => ts('FK to Membership Status'),
341 'where' => 'civicrm_membership.status_id',
342 'headerPattern' => '/(member(ship|).)?(status)$/i',
344 'table_name' => 'civicrm_membership',
345 'entity' => 'Membership',
346 'bao' => 'CRM_Member_BAO_Membership',
348 'FKClassName' => 'CRM_Member_DAO_MembershipStatus',
352 'pseudoconstant' => [
353 'table' => 'civicrm_membership_status',
355 'labelColumn' => 'label',
359 'member_is_override' => [
360 'name' => 'is_override',
361 'type' => CRM_Utils_Type
::T_BOOLEAN
,
362 'title' => ts('Status Override'),
363 '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.'),
365 'where' => 'civicrm_membership.is_override',
366 'headerPattern' => '/override$/i',
368 'table_name' => 'civicrm_membership',
369 'entity' => 'Membership',
370 'bao' => 'CRM_Member_BAO_Membership',
373 'type' => 'CheckBox',
377 'status_override_end_date' => [
378 'name' => 'status_override_end_date',
379 'type' => CRM_Utils_Type
::T_DATE
,
380 'title' => ts('Status Override End Date'),
381 'description' => ts('Then end date of membership status override if \'Override until selected date\' override type is selected.'),
383 'where' => 'civicrm_membership.status_override_end_date',
386 'table_name' => 'civicrm_membership',
387 'entity' => 'Membership',
388 'bao' => 'CRM_Member_BAO_Membership',
391 'type' => 'Select Date',
392 'formatType' => 'activityDate',
396 'owner_membership_id' => [
397 'name' => 'owner_membership_id',
398 'type' => CRM_Utils_Type
::T_INT
,
399 'title' => ts('Primary Member ID'),
400 'description' => ts('Optional FK to Parent Membership.'),
401 'where' => 'civicrm_membership.owner_membership_id',
403 'table_name' => 'civicrm_membership',
404 'entity' => 'Membership',
405 'bao' => 'CRM_Member_BAO_Membership',
407 'FKClassName' => 'CRM_Member_DAO_Membership',
411 'name' => 'max_related',
412 'type' => CRM_Utils_Type
::T_INT
,
413 'title' => ts('Max Related'),
414 'description' => ts('Maximum number of related memberships (membership_type override).'),
415 'where' => 'civicrm_membership.max_related',
417 'table_name' => 'civicrm_membership',
418 'entity' => 'Membership',
419 'bao' => 'CRM_Member_BAO_Membership',
426 'member_is_test' => [
428 'type' => CRM_Utils_Type
::T_BOOLEAN
,
429 'title' => ts('Test'),
431 'where' => 'civicrm_membership.is_test',
432 'headerPattern' => '/(is.)?test(.member(ship)?)?/i',
435 'table_name' => 'civicrm_membership',
436 'entity' => 'Membership',
437 'bao' => 'CRM_Member_BAO_Membership',
440 'type' => 'CheckBox',
444 'member_is_pay_later' => [
445 'name' => 'is_pay_later',
446 'type' => CRM_Utils_Type
::T_BOOLEAN
,
447 'title' => ts('Is Pay Later'),
449 'where' => 'civicrm_membership.is_pay_later',
450 'headerPattern' => '/(is.)?(pay(.)?later)$/i',
453 'table_name' => 'civicrm_membership',
454 'entity' => 'Membership',
455 'bao' => 'CRM_Member_BAO_Membership',
458 'type' => 'CheckBox',
462 'membership_recur_id' => [
463 'name' => 'contribution_recur_id',
464 'type' => CRM_Utils_Type
::T_INT
,
465 'title' => ts('Membership Recurring Contribution'),
466 '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.'),
467 'where' => 'civicrm_membership.contribution_recur_id',
469 'table_name' => 'civicrm_membership',
470 'entity' => 'Membership',
471 'bao' => 'CRM_Member_BAO_Membership',
473 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
476 'member_campaign_id' => [
477 'name' => 'campaign_id',
478 'type' => CRM_Utils_Type
::T_INT
,
479 'title' => ts('Campaign'),
480 'description' => ts('The campaign for which this membership is attached.'),
482 'where' => 'civicrm_membership.campaign_id',
484 'table_name' => 'civicrm_membership',
485 'entity' => 'Membership',
486 'bao' => 'CRM_Member_BAO_Membership',
488 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
492 'pseudoconstant' => [
493 'table' => 'civicrm_campaign',
495 'labelColumn' => 'title',
500 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
502 return Civi
::$statics[__CLASS__
]['fields'];
506 * Return a mapping from field-name to the corresponding key (as used in fields()).
509 * Array(string $name => string $uniqueName).
511 public static function &fieldKeys() {
512 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
513 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
515 return Civi
::$statics[__CLASS__
]['fieldKeys'];
519 * Returns the names of this table
523 public static function getTableName() {
524 return self
::$_tableName;
528 * Returns if this table needs to be logged
532 public function getLog() {
537 * Returns the list of fields that can be imported
539 * @param bool $prefix
543 public static function &import($prefix = FALSE) {
544 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'membership', $prefix, []);
549 * Returns the list of fields that can be exported
551 * @param bool $prefix
555 public static function &export($prefix = FALSE) {
556 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'membership', $prefix, []);
561 * Returns the list of indices
563 * @param bool $localize
567 public static function indices($localize = TRUE) {
569 'index_owner_membership_id' => [
570 'name' => 'index_owner_membership_id',
572 0 => 'owner_membership_id',
574 'localizable' => FALSE,
575 'sig' => 'civicrm_membership::0::owner_membership_id',
578 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;