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:9a307c1a63b4df70ae38f36ce4171cb6)
13 * Database access object for the Membership entity.
15 class CRM_Member_DAO_Membership
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_membership';
25 * Icon associated with this entity.
29 public static $_icon = 'fa-id-badge';
32 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 public static $_log = TRUE;
53 * FK to Membership Type
57 public $membership_type_id;
60 * Beginning of initial membership period (member since...).
67 * Beginning of current uninterrupted membership period.
74 * Current membership period expire date.
86 * FK to Membership Status
93 * 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.
100 * Then end date of membership status override if 'Override until selected date' override type is selected.
104 public $status_override_end_date;
107 * Optional FK to Parent Membership.
111 public $owner_membership_id;
114 * Maximum number of related memberships (membership_type override).
128 public $is_pay_later;
131 * 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.
135 public $contribution_recur_id;
138 * The campaign for which this membership is attached.
147 public function __construct() {
148 $this->__table
= 'civicrm_membership';
149 parent
::__construct();
153 * Returns localized title of this entity.
155 public static function getEntityTitle() {
156 return ts('Memberships');
160 * Returns foreign keys and entity references.
163 * [CRM_Core_Reference_Interface]
165 public static function getReferenceColumns() {
166 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
167 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
168 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
169 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'membership_type_id', 'civicrm_membership_type', 'id');
170 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'status_id', 'civicrm_membership_status', 'id');
171 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'owner_membership_id', 'civicrm_membership', 'id');
172 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_recur_id', 'civicrm_contribution_recur', 'id');
173 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
174 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
176 return Civi
::$statics[__CLASS__
]['links'];
180 * Returns all the column names of this table
184 public static function &fields() {
185 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
186 Civi
::$statics[__CLASS__
]['fields'] = [
189 'type' => CRM_Utils_Type
::T_INT
,
190 'title' => ts('Membership ID'),
191 'description' => ts('Membership Id'),
194 'where' => 'civicrm_membership.id',
195 'headerPattern' => '/^(m(embership\s)?id)$/i',
197 'table_name' => 'civicrm_membership',
198 'entity' => 'Membership',
199 'bao' => 'CRM_Member_BAO_Membership',
203 'membership_contact_id' => [
204 'name' => 'contact_id',
205 'type' => CRM_Utils_Type
::T_INT
,
206 'title' => ts('Contact ID'),
207 'description' => ts('FK to Contact ID'),
210 'where' => 'civicrm_membership.contact_id',
211 'headerPattern' => '/contact(.?id)?/i',
212 'dataPattern' => '/^\d+$/',
214 'table_name' => 'civicrm_membership',
215 'entity' => 'Membership',
216 'bao' => 'CRM_Member_BAO_Membership',
218 'FKClassName' => 'CRM_Contact_DAO_Contact',
220 'type' => 'EntityRef',
224 'membership_type_id' => [
225 'name' => 'membership_type_id',
226 'type' => CRM_Utils_Type
::T_INT
,
227 'title' => ts('Membership Type Id'),
228 'description' => ts('FK to Membership Type'),
231 'where' => 'civicrm_membership.membership_type_id',
232 'headerPattern' => '/^(m(embership\s)?type)$/i',
234 'table_name' => 'civicrm_membership',
235 'entity' => 'Membership',
236 'bao' => 'CRM_Member_BAO_Membership',
238 'FKClassName' => 'CRM_Member_DAO_MembershipType',
241 'label' => ts("Membership Type"),
243 'pseudoconstant' => [
244 'table' => 'civicrm_membership_type',
246 'labelColumn' => 'name',
250 'membership_join_date' => [
251 'name' => 'join_date',
252 'type' => CRM_Utils_Type
::T_DATE
,
253 'title' => ts('Member Since'),
254 'description' => ts('Beginning of initial membership period (member since...).'),
256 'where' => 'civicrm_membership.join_date',
257 'headerPattern' => '/^join|(j(oin\s)?date)$/i',
258 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
260 'table_name' => 'civicrm_membership',
261 'entity' => 'Membership',
262 'bao' => 'CRM_Member_BAO_Membership',
265 'type' => 'Select Date',
266 'formatType' => 'activityDate',
270 'membership_start_date' => [
271 'name' => 'start_date',
272 'type' => CRM_Utils_Type
::T_DATE
,
273 'title' => ts('Membership Start Date'),
274 'description' => ts('Beginning of current uninterrupted membership period.'),
276 'where' => 'civicrm_membership.start_date',
277 'headerPattern' => '/(member(ship)?.)?start(s)?(.date$)?/i',
278 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
280 'table_name' => 'civicrm_membership',
281 'entity' => 'Membership',
282 'bao' => 'CRM_Member_BAO_Membership',
285 'type' => 'Select Date',
286 'formatType' => 'activityDate',
290 'membership_end_date' => [
291 'name' => 'end_date',
292 'type' => CRM_Utils_Type
::T_DATE
,
293 'title' => ts('Membership Expiration Date'),
294 'description' => ts('Current membership period expire date.'),
296 'where' => 'civicrm_membership.end_date',
297 'headerPattern' => '/(member(ship)?.)?end(s)?(.date$)?/i',
298 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
300 'table_name' => 'civicrm_membership',
301 'entity' => 'Membership',
302 'bao' => 'CRM_Member_BAO_Membership',
305 'type' => 'Select Date',
306 'formatType' => 'activityDate',
310 'membership_source' => [
312 'type' => CRM_Utils_Type
::T_STRING
,
313 'title' => ts('Source'),
315 'size' => CRM_Utils_Type
::HUGE
,
317 'where' => 'civicrm_membership.source',
318 'headerPattern' => '/^(member(ship?))?source$/i',
320 'table_name' => 'civicrm_membership',
321 'entity' => 'Membership',
322 'bao' => 'CRM_Member_BAO_Membership',
330 'name' => 'status_id',
331 'type' => CRM_Utils_Type
::T_INT
,
332 'title' => ts('Membership Status Id'),
333 'description' => ts('FK to Membership Status'),
336 'where' => 'civicrm_membership.status_id',
337 'headerPattern' => '/(member(ship|).)?(status)$/i',
339 'table_name' => 'civicrm_membership',
340 'entity' => 'Membership',
341 'bao' => 'CRM_Member_BAO_Membership',
343 'FKClassName' => 'CRM_Member_DAO_MembershipStatus',
347 'pseudoconstant' => [
348 'table' => 'civicrm_membership_status',
350 'labelColumn' => 'label',
354 'member_is_override' => [
355 'name' => 'is_override',
356 'type' => CRM_Utils_Type
::T_BOOLEAN
,
357 'title' => ts('Status Override'),
358 '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.'),
360 'where' => 'civicrm_membership.is_override',
361 'headerPattern' => '/override$/i',
363 'table_name' => 'civicrm_membership',
364 'entity' => 'Membership',
365 'bao' => 'CRM_Member_BAO_Membership',
368 'type' => 'CheckBox',
372 'status_override_end_date' => [
373 'name' => 'status_override_end_date',
374 'type' => CRM_Utils_Type
::T_DATE
,
375 'title' => ts('Status Override End Date'),
376 'description' => ts('Then end date of membership status override if \'Override until selected date\' override type is selected.'),
378 'where' => 'civicrm_membership.status_override_end_date',
381 'table_name' => 'civicrm_membership',
382 'entity' => 'Membership',
383 'bao' => 'CRM_Member_BAO_Membership',
386 'type' => 'Select Date',
387 'formatType' => 'activityDate',
391 'owner_membership_id' => [
392 'name' => 'owner_membership_id',
393 'type' => CRM_Utils_Type
::T_INT
,
394 'title' => ts('Primary Member ID'),
395 'description' => ts('Optional FK to Parent Membership.'),
396 'where' => 'civicrm_membership.owner_membership_id',
398 'table_name' => 'civicrm_membership',
399 'entity' => 'Membership',
400 'bao' => 'CRM_Member_BAO_Membership',
402 'FKClassName' => 'CRM_Member_DAO_Membership',
406 'name' => 'max_related',
407 'type' => CRM_Utils_Type
::T_INT
,
408 'title' => ts('Max Related'),
409 'description' => ts('Maximum number of related memberships (membership_type override).'),
410 'where' => 'civicrm_membership.max_related',
412 'table_name' => 'civicrm_membership',
413 'entity' => 'Membership',
414 'bao' => 'CRM_Member_BAO_Membership',
421 'member_is_test' => [
423 'type' => CRM_Utils_Type
::T_BOOLEAN
,
424 'title' => ts('Test'),
426 'where' => 'civicrm_membership.is_test',
427 'headerPattern' => '/(is.)?test(.member(ship)?)?/i',
430 'table_name' => 'civicrm_membership',
431 'entity' => 'Membership',
432 'bao' => 'CRM_Member_BAO_Membership',
435 'type' => 'CheckBox',
439 'member_is_pay_later' => [
440 'name' => 'is_pay_later',
441 'type' => CRM_Utils_Type
::T_BOOLEAN
,
442 'title' => ts('Is Pay Later'),
444 'where' => 'civicrm_membership.is_pay_later',
445 'headerPattern' => '/(is.)?(pay(.)?later)$/i',
448 'table_name' => 'civicrm_membership',
449 'entity' => 'Membership',
450 'bao' => 'CRM_Member_BAO_Membership',
453 'type' => 'CheckBox',
457 'membership_recur_id' => [
458 'name' => 'contribution_recur_id',
459 'type' => CRM_Utils_Type
::T_INT
,
460 'title' => ts('Membership Recurring Contribution'),
461 '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.'),
462 'where' => 'civicrm_membership.contribution_recur_id',
464 'table_name' => 'civicrm_membership',
465 'entity' => 'Membership',
466 'bao' => 'CRM_Member_BAO_Membership',
468 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
471 'member_campaign_id' => [
472 'name' => 'campaign_id',
473 'type' => CRM_Utils_Type
::T_INT
,
474 'title' => ts('Campaign'),
475 'description' => ts('The campaign for which this membership is attached.'),
477 'where' => 'civicrm_membership.campaign_id',
479 'table_name' => 'civicrm_membership',
480 'entity' => 'Membership',
481 'bao' => 'CRM_Member_BAO_Membership',
483 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
487 'pseudoconstant' => [
488 'table' => 'civicrm_campaign',
490 'labelColumn' => 'title',
495 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
497 return Civi
::$statics[__CLASS__
]['fields'];
501 * Return a mapping from field-name to the corresponding key (as used in fields()).
504 * Array(string $name => string $uniqueName).
506 public static function &fieldKeys() {
507 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
508 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
510 return Civi
::$statics[__CLASS__
]['fieldKeys'];
514 * Returns the names of this table
518 public static function getTableName() {
519 return self
::$_tableName;
523 * Returns if this table needs to be logged
527 public function getLog() {
532 * Returns the list of fields that can be imported
534 * @param bool $prefix
538 public static function &import($prefix = FALSE) {
539 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'membership', $prefix, []);
544 * Returns the list of fields that can be exported
546 * @param bool $prefix
550 public static function &export($prefix = FALSE) {
551 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'membership', $prefix, []);
556 * Returns the list of indices
558 * @param bool $localize
562 public static function indices($localize = TRUE) {
564 'index_owner_membership_id' => [
565 'name' => 'index_owner_membership_id',
567 0 => 'owner_membership_id',
569 'localizable' => FALSE,
570 'sig' => 'civicrm_membership::0::owner_membership_id',
573 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;